Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » TableGenerator and Default-Value pkColumnValue(Multible GeneratedValue with one TableGenerator.)
TableGenerator and Default-Value pkColumnValue [message #760373] Fri, 02 December 2011 08:25 Go to next message
Rene  is currently offline Rene Friend
Messages: 1
Registered: December 2011
Junior Member
Hello,
I can't understand the relation between @GeneratedValue and @TableGenerator.
How can I define one (!) Tablegenerator in an Entity per Annotation or with an orm.xml
and then use this Generator multible from different Entities?
In the hibernate implementation this works, because the default value for the "pkColumnValue" attribute ist the db-table name. So I implement in the Entities
only the @GeneratedValue.

orm.xml:
<table-generator name="myGlobalSequenzer" table="seqenzer" pk-column-name="seq_name" value-column-name="seq_value" />

Entity 1..n
@GeneratedValue(strategy=GenerationType.TABLE, generator="myGlobalSequenzer")

table: seqenzer
********************
seq_name seq_value
********************
customer 100
address 57
...

Why is the default value in eclipselink for "pkColumnValue" the generator name!?
I think this is nonsens.

thx
rené



Re: TableGenerator and Default-Value pkColumnValue [message #760514 is a reply to message #760373] Fri, 02 December 2011 16:27 Go to previous message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
Hello,

The JPA specification defined the pkColumnValue within the TableGenerator annotation and table-generator xml tag making it specific to that generator - it essentially defines a sequence object. Reusing the same generator means you wish to have that generated value use the same sequence object.

For table sequencing, allowing reusing the same TableGenerator makes sense to use different rows for each generator. Please file a feature request to allow configuring reusing the same TableGenerator name in the GeneratedValue to use different sequence objects/rows in the sequence table.

EclipseLink does this if you use the defaults entirely - just use the @GeneratedValue(strategy=GenerationType.TABLE) annotation instead, and each entity will default to its own generator using the same SEQUENCE Table. You could also reuse the tablegenerator names, and create a generic customizer for each entity that changed the values of the pkColumnValue within the sequence object on the EclipseLink descriptor to the default value you wanted. I haven't looked at the code that would be involved in doing so, but will if you wanted to go down this path.

Best Regards,
Chris
Re: TableGenerator and Default-Value pkColumnValue [message #760515 is a reply to message #760373] Fri, 02 December 2011 16:27 Go to previous message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
Hello,

The JPA specification defined the pkColumnValue within the TableGenerator annotation and table-generator xml tag making it specific to that generator - it essentially defines a sequence object. Reusing the same generator means you wish to have that generated value use the same sequence object.

For table sequencing, allowing reusing the same TableGenerator makes sense to use different rows for each generator. Please file a feature request to allow configuring reusing the same TableGenerator name in the GeneratedValue to use different sequence objects/rows in the sequence table.

EclipseLink does this if you use the defaults entirely - just use the @GeneratedValue(strategy=GenerationType.TABLE) annotation instead, and each entity will default to its own generator using the same SEQUENCE Table. You could also reuse the tablegenerator names, and create a generic customizer for each entity that changed the values of the pkColumnValue within the sequence object on the EclipseLink descriptor to the default value you wanted. I haven't looked at the code that would be involved in doing so, but will if you wanted to go down this path.

Best Regards,
Chris
Previous Topic:Exception Description: DatabaseAccessor not connected.
Next Topic:LazyInitializationException with JAXB
Goto Forum:
  


Current Time: Tue Nov 05 10:08:13 GMT 2024

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

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

Back to the top