[forge-dev] @GeneratedValue Strategy

Ryan Bradley rbradley at redhat.com
Fri May 4 10:15:09 EDT 2012


Greetings all,

Currently, the entity plugin annotates the ID primary key with 
@GeneratedValue.  This annotation uses the default generation strategy, 
GenerationType.AUTO, to generate the values for this key.  Using this 
strategy, the same set of values is used for all entity tables.  In 
other words, you cannot have two entities with the same value for ID, as 
it is incremented with each entity creation rather than with each 
creation of an entity of a specific type.

Thinking of scaffold implementations, it might be best if a separate set 
of IDs was generated for each separate entity.  I believe that this can 
be accomplished by annotating the field with 
@GeneratedValue(strategy=GenerationType.IDENTITY).  I was thinking of 
modifying the ScaffoldPlugin to change the GenerationType on this 
annotation in the generateFromEntity method (from-entity command).

Any objections to this change?

Cheers,
Ryan


More information about the forge-dev mailing list