You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by shoevarek <va...@gmail.com> on 2013/03/08 03:01:37 UTC

Query on many to many relationship

Hello. I have two entities - CodeDecode and Filter with many to many
biderectional relationship. In data model I have dedicated mapping table
that stores code_decode_id and filter_id associtations. In my entity
configuration I have used @JoinTable annotation to specify join and inverse
join columns I selected CodeDecode as an owner of relationship.

I want to retrieve all CodeDecode for which Filter has specified name. I
also want to return that Filter data. I have created a dynamic query that
correctly returns me collection of CodeDecode entities based on different
search criteria. The problem I am facing is that I do not know how to
retrieve only those Filter entities that were requested. I either get all
entities associated with specific CodeDecode (when I use join fetch) or no
filters at all (when I execute separte search just to get specific filter
entity - it is not mapped/associated with CodeDecode entities that are
already loaded in peristsence context).

What is the way of implementing such query using JPA? Would appreciate any
help.



--
View this message in context: http://openjpa.208410.n2.nabble.com/Query-on-many-to-many-relationship-tp7583048.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.