Not able to create query findByUserId(Long userId) I have tried findByUserId(Long user_id) findByuser_id(Long user_id) findByUser_id(Long user_id)
CodePudding user response:
Your JPA method, as currently named, expects a user ID variable name of userId
, in camel case. Use this definition:
@Column(name="user_id")
private Long userId;
Then use findByUserId(Long userId)
as the JPA repo method name as you were already doing. Note that the @Column
annotation directs JPA/Hibernate to create the table column with the name user_id
.