在扩展 JPA 的 UserRepository 中查询
Query in UserRepository which extends JPA
我一直在尝试通过我的 MySQL 数据库中的用户名和密码获取用户,但我不断收到这些错误。
@Query("select u from User where u.username = :username and u.password = :password")
public User findByUsernameAndPassword(@Param("username") String username,
@Param("password") String password);
错误:
Caused by: java.lang.IllegalArgumentException: org.hibernate.QueryException: Unable to resolve path [u.username], unexpected token [u] [select u from com.Rest.GolfMax.API.Users.User where u.username = :username and u.password = :password]
Caused by: org.hibernate.QueryException: Unable to resolve path [u.username], unexpected token [u]
语法中的一个小错误,我修正了它:
@Query("select u from User u where u.username = :username and u.password = :password")
如果您不对密码进行编码,那么这对您有用。但我建议出于这些目的使用 Spring 安全性。
我一直在尝试通过我的 MySQL 数据库中的用户名和密码获取用户,但我不断收到这些错误。
@Query("select u from User where u.username = :username and u.password = :password")
public User findByUsernameAndPassword(@Param("username") String username,
@Param("password") String password);
错误:
Caused by: java.lang.IllegalArgumentException: org.hibernate.QueryException: Unable to resolve path [u.username], unexpected token [u] [select u from com.Rest.GolfMax.API.Users.User where u.username = :username and u.password = :password]
Caused by: org.hibernate.QueryException: Unable to resolve path [u.username], unexpected token [u]
语法中的一个小错误,我修正了它:
@Query("select u from User u where u.username = :username and u.password = :password")
如果您不对密码进行编码,那么这对您有用。但我建议出于这些目的使用 Spring 安全性。