I have defined an interface for the User entity called UserRepository and it has defined one method that should allow it to find the matching user based upon the user_name:
Then in my controller code I have the following usage:Code:public interface UserRepository extends JpaRepository<User, Integer> { User findByUserName( String userName ); }
In the spring data jpa doc (http://static.springsource.org/sprin...ty-expressions) 1.3.2.2. Query creation it seems to indicate that this is what should be done. However when I run this at the login where the find would be executed I get:Code:@Controller @SessionAttributes public class LoginController { @Autowired UserRepository userRepo; @RequestMapping( value = "/loginForm", method = RequestMethod.POST ) public String loginUser( @Valid LoginForm loginForm, BindingResult result ) { User logUser = userRepo.findByUserName( loginForm.getUserName() ); ... } }
org.springframework.dao.InvalidDataAccessApiUsageE xception: The type [null] is not the expected [EntityType] for the key class [class com.diodesign.fitness.jpa.entities.User].; nested exception is java.lang.IllegalArgumentException: The type [null] is not the expected [EntityType] for the key class [class com.diodesign.fitness.jpa.entities.User].
Any suggestions as to how to fix this?
Thanks


Reply With Quote
