What is wrong with my HQL query? Does not return the user for a given token (this token in the database is 100%).
HQL
@Query("SELECT u FROM User u inner join u.session s where s.token = :session") User getUserBySession(@Param("session") String session);
User
@Entity @Table(name = "\"user\"") public class User{ @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; @OneToOne private Session session;
Session
@Entity @Table(name="session") public class Session { @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; private String token; @OneToOne @JoinColumn(name = "userid") private User user;
SELECT u FROM User u inner join u.session s where s.token = :session
If the query is valid, then: 1) there is a database namedu
2) It has a table calledsession
3) it has atoken
field 4) in The current database has a table namedUser
5) in one of these tables there is a field namedu
. If at least one of this is incorrect, then the request is also incorrect. - AkinaUser
andSession
in normal SQL - then I will prompt. - Akina