Searching An object from @ElementCollection

前端 未结 4 2089
野性不改
野性不改 2021-02-19 06:16

I am using Spring Data JPA.

I an entity like this

public class A {

    @CollectionTable(name = \"B_ITEMS\", joinColumns = @JoinColumn(name = \"B_ID\"))
         


        
4条回答
  •  猫巷女王i
    2021-02-19 06:37

    @ElementCollection is just a simple way to map a @OneToMany relation.

    As such you can join them as usual:

    public interface ARepo extends PagingAndSortingRepository {
        @Query("select a from A a join a.bs b where b.prop1 = :prop1 and ...")
        A findByProps(@Param("prop1") String prop1)
    }
    

提交回复
热议问题