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 = :sessionIf the query is valid, then: 1) there is a database namedu2) It has a table calledsession3) it has atokenfield 4) in The current database has a table namedUser5) in one of these tables there is a field namedu. If at least one of this is incorrect, then the request is also incorrect. - AkinaUserandSessionin normal SQL - then I will prompt. - Akina