@ManyToOne relation problem [message #387082] |
Fri, 10 April 2009 14:30 |
Somebody Somebody Messages: 2 Registered: July 2009 |
Junior Member |
|
|
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 ?
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02059 seconds