Skip to main content



      Home
Home » Eclipse Projects » EclipseLink » @ManyToOne relation problem
@ManyToOne relation problem [message #387082] Fri, 10 April 2009 10:30 Go to next message
Eclipse UserFriend
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 ?
Re: @ManyToOne relation problem [message #387088 is a reply to message #387082] Tue, 14 April 2009 04:15 Go to previous messageGo to next message
Eclipse UserFriend
Any idea ?
Re: @ManyToOne relation problem [message #387094 is a reply to message #387082] Wed, 15 April 2009 09:32 Go to previous message
Eclipse UserFriend
JPA only allows relationships to be define using foreign keys
(JoinColumn). However in EclipseLink you can define complex relationships
such as this using the Expression criteria API and a DescriptorCustomizer.

See,
http://wiki.eclipse.org/EclipseLink/Examples/JPA/MappingSele ctionCriteria

---
James
http://www.nabble.com/EclipseLink---Users-f26658.html
Previous Topic:multiple xml-mappings from fragments?
Next Topic:@Version field does partially update?
Goto Forum:
  


Current Time: Wed Jul 16 03:04:16 EDT 2025

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

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

Back to the top