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 18:03 Go to next message
Mark Hoffmann is currently offline Mark Hoffmann
Messages: 102
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 13:40 Go to previous message
James Sutherland is currently offline James Sutherland
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: Wed Aug 20 14:34:57 EDT 2014

Powered by FUDForum. Page generated in 0.09653 seconds