Spring Data JPA: query ManyToMany

后端 未结 3 505
庸人自扰
庸人自扰 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:15

    I was using @JoinTable and I got it working with this :

    @Query("select t from Test t join t.users u where u.username = :username")
    List findAllByUsername(@Param("username") String username);
    

    t.users u instead of User u

提交回复
热议问题