Skip to main content



      Home
Home » Eclipse Projects » EclipseLink » OneToMany with composite keys(Problems creating OneToMany relationship for tables with composite keys)
OneToMany with composite keys [message #882911] Thu, 07 June 2012 09:10 Go to next message
Eclipse UserFriend
Hi,

Using EclipseLink 2.3.2. Db is HSQLDB (for testing). I'm trying model part of a legacy data base schema, which I cannot change. There is one particular relationship which I have not been able to create:

There is a conceptual one-to-many relationship between TableA and TableB:

TableA
id (pk)
sequence (pk)
tableBid (fk)

TableB
id (pk)
sequence(pk)
value

So TableA references half of TableB's composite primary key. I suppose it could be argued that this is a many-to-many relationship since there is no guarantee that the same row in table B will not be referenced by several rows in table A. Would I have to model this as a many-to-many and create a link table or is there any other way of molelling this?
Re: OneToMany with composite keys [message #885157 is a reply to message #882911] Tue, 12 June 2012 10:43 Go to previous message
Eclipse UserFriend
If the id in B is unique, then you could just make it the Id in your entity and ignore the sequence as the id.

If it is not unique, then this is an odd relationship, you could model it using a selectionCriteria on the mapping, or using a DescriptorCustomizer to just set the one foreign key (instead of the two that get defaulted).

See,
http://wiki.eclipse.org/EclipseLink/Examples/JPA/MappingSelectionCriteria
Previous Topic:MOXy jaxb binding error for redefine element
Next Topic:Understanding internals
Goto Forum:
  


Current Time: Tue Jul 22 20:28:01 EDT 2025

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

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

Back to the top