JPQL query: how to filter rows on a relationship?

前端 未结 1 1246
暗喜
暗喜 2021-01-15 02:21

I\'m new to JPA 2.0 and there are few things I don\'t understand.

I have a couple of tables:



    CUST table (for customers)
    -------------------         


        
相关标签:
1条回答
  • 2021-01-15 03:00

    JPA deals with objects, and an object has an identity and is the same no matter how it is queried. No matter what your where clause is, the Customer objects returned are still the same Customer objects and should have the same relationships. This is important for caching, object identity and consistency.

    Your second query is probably the correct way to do what you want. It is possible to do what your are trying to do using an alias on a JOIN FETCH (as of EclipseLink 2.4), but not recommended.

    See, http://wiki.eclipse.org/EclipseLink/UserGuide/JPA/Basic_JPA_Development/Querying/JPQL#JOIN_FETCH

    0 讨论(0)
提交回复
热议问题