Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Query across Variable One to One mapping(Query across Variable One to One mapping)
Query across Variable One to One mapping [message #537838] Thu, 03 June 2010 19:41 Go to next message
Doug Gschwind is currently offline Doug GschwindFriend
Messages: 18
Registered: July 2009
Junior Member
Hi, lets say I have an interface I, and I have two implementors of that interface A and B. Now lets say I have established a Variable one to one relationship from a class X to I via the EclipseLink VariableOneToOne JPA extension annotation.

How can I write a JPQL query that will find me all instances of X via an EntityManager, where those instances of X reference an I implementor that is in a given state? For example, I wish to find all instances of X where the instance references an instance of A or B, such that an int property of A or B (expressed as an operation on I?) has a given value such as 5.

Thank you,

Doug
Re: Query across Variable One to One mapping [message #538463 is a reply to message #537838] Mon, 07 June 2010 16:47 Go to previous message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

Joins are not supported across VariableOneToOne relationships, so this is not easy to do. Since there are two or more different tables/entities you will need to query or join multiple tables.

One option is to define a OneToOneQueryKey to both of the implementers of the Interface and in your query join both of the query keys. Note that query key support to JPQL was added in EclipseLink 2.1, previously you would need to use an Expression (or Criteria) query to access query keys.

Another option is to use a native SQL query, or switch the mapping to two different OneToOne mappings.

Please log an enhancement request to have support for joining VariableOneToOne relationships and vote for it.


James : Wiki : Book : Blog : Twitter
Previous Topic:Storing empty strings in an oracle database
Next Topic:Obtaining Instance of Connection from EM
Goto Forum:
  


Current Time: Wed Apr 24 18:51:14 GMT 2024

Powered by FUDForum. Page generated in 0.02710 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top