[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.rt.eclipselink] @ManyToOne relation problem

Hi,

I have a dilemma:

+ I have 2 entities with a ManyToOne relationship and no unique ids (Embedded ids):

Entity A (date, field1, field2)
Entity B (field1, field2, startDate, endDate)

+ Primary key of Entity B is an embedded id composed by field1, field2, and startDate.

+ Relationship between EntityA and EntityB

SELECT EntityB.*
FROM EntityA, EntityB
WHERE EntityB.field1 = EntityA.field1
AND EntityB.field2 = EntityA.field2
AND EntityB.startDate <= EntityA.date
AND EntityB.endDate > EntityA.date

It always return an unique row.

=> Is it possible to establish the relationship between EntityA and Entity B with JPA annotations to fetch EntityA rows or I need to use a JPQL query to make the join ?