Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Calculated Primary Key
Calculated Primary Key [message #555800] Sat, 28 August 2010 22:03 Go to next message
Mark Hoffmann is currently offline Mark HoffmannFriend
Messages: 113
Registered: July 2009
Location: Jena
Senior Member
Hi all,

I want to integrate pseudonymization / depseudonymization using JPA. Imagine a one to many relationship between a customer and many orders. The order entity should contain a foreign key of type string. This foreign key is calculated from a Java implementation using fields from the customer entity. This implementation creates the foreign key value from the three fields and extracts the three fields from a given foreign key value.

The customer entity will have a compound primary key class(firstname, lastname, birthdate). The problem is that the key in customer are in this example 3 fields and the reference in the order is one calculated value of this fields. Is there a hook which I could use in EclipseLink? Or do I have to extend EclipseLink? Is this barely possible?

I don't know how to solve this problem unless I want to use the convenient @OneToMany in the customer entity.

Any ideas?

Regards,
Mark
Re: Calculated Primary Key [message #556075 is a reply to message #555800] Mon, 30 August 2010 17:40 Go to previous message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

EclipseLink allows you to define complex relationships based on an Expression.

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

You can use the fields in the expression to compute a foreign key value.



James : Wiki : Book : Blog : Twitter
Previous Topic:Problem with DB2
Next Topic:Lazy is not lazy
Goto Forum:
  


Current Time: Fri Apr 26 20:32:33 GMT 2024

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

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

Back to the top