Spring Data JPA: query ManyToMany

后端 未结 3 502
庸人自扰
庸人自扰 2020-11-29 05:33

I have entities User and Test

@Entity
public class User {
    private Long id;
    private String userName;
}

@Entity
public class         


        
3条回答
  •  醉梦人生
    2020-11-29 06:20

    The following method signature will get you want to want:

    List findByUsers_UserName(String userName)
    

    This is using the property expression feature of Spring Data JPA. The signature Users_UserName will be translated to the JPQL x.users.userName. Note that this will perform an exact match on the given username.

提交回复
热议问题