|TableGenerator Sequencing options [message #644221]
||Fri, 10 December 2010 02:06
| Dave Brosius
Registered: July 2009
We have a collection of legacy applications all around a common schema, running on a common database instance. For primary keys we use the the table based next key pattern, using a legacy (read adhoc) implementation of that algorithm.
We are introducing a new product into this environment, same schema, save database instance. However since it's new, we are using JPA and EclipseLink to do our database management.
We have specified the TableGenerator annotation using the same table and field names and values as is used with the legacy products.
However we've stumbled upon a mismatch that is a problem.
In our legacy system, the value of the key in the table is the value of the 'next key'. That is, the legacy products retrieve the value in the table, use that for a primary key, and then increment the value in the table.
JPA(EclipseLink) on the other hand, increments the value in the table, and uses the incremented value as the primary key.
Thus if the new product using JPA gets a new primary key, and then the legacy system gets a primary key, there will be key collision.
As we'd rather not fuss with a suite of venerable products, we were hoping to solve this with JPA.
Is there a way to instruct JPA to switch how it uses keys in a TableGenerator, ie we'd like it to use the value it finds in the table for the next key, and then increment that key for the next use?
Powered by FUDForum
. Page generated in 0.01552 seconds