dev@glassfish.java.net

Re: Default Table name for Table Generator

From: Marina Vatkina <Marina.Vatkina_at_Sun.COM>
Date: Mon, 18 Jun 2007 12:02:09 -0700

These are the rules that should be published in the next (9.1) dev guide:

@GeneratedValue defaults are as follows:

     * Using strategy=AUTO (or no strategy) creates a @TableGenerator named
SEQ_GEN with default settings. Specifying a generator has no effect.
     * Using strategy=TABLE without specifying a generator creates a
@TableGenerator named SEQ_GEN_TABLE with default settings. Specifying a
generator but no @TableGenerator creates and names a @TableGenerator with
default settings.
     * Using strategy=IDENTITY or strategy=SEQUENCE produces the same results,
which are database-specific.
           o For Oracle databases, not specifying a generator creates a
@SequenceGenerator named SEQ_GEN_SEQUENCE with default settings. Specifying a
generator but no @SequenceGenerator creates and names a @SequenceGenerator with
default settings.
           o For PostgreSQL databases, a SERIAL column named
entity-table_pk-column_SEQ is created.
           o For MySQL databases, an AUTO_INCREMENT column is created.
           o For other supported databases, an IDENTITY column is created.

The @SequenceGenerator annotation has one default specific to the default
provider. The default sequenceName is the specified name.

@TableGenerator defaults are as follows:

     * The default table is SEQUENCE.
     * The default pkColumnName is SEQ_NAME.
     * The default valueColumnName is SEQ_COUNT.
     * The default pkColumnValue is the specified name.


-marina

Markus KARG wrote:
> Gordon Yorke schrieb:
>
>> The default table name is SEQUENCE and this table will be shared by
>> all entities that do not have a generator defined.
>> --Gordon
>>
>
> Sorry I did not ask precisely enough. I have set up the SEQUENCE table
> already -- otherwise (strategy=TABLE,generator="foo") wouldn't work,
> obviously. What I wanted to ask was not the default table name, but the
> default GENERATOR name. So if I do not specify generator="foo", what is
> the default generator's name?
>
> Thanks
> Markus
>
>> -----Original Message-----
>> From: Markus KARG [mailto:markus.karg_at_gmx.net]
>> Sent: Sunday, June 17, 2007 2:54 AM
>> To: dev_at_glassfish.dev.java.net
>> Subject: Default Table name for Table Generator
>>
>>
>> When I specify @GeneratedValue(strategy=TABLE,generator="foo") then GF
>> is using the table "foo" for generating IDs.
>> If I just specify @GeneratedValue(strategy=TABLE), what is the default
>> table name that GF with actually use at runtime?
>> As a "simple user" I expected that GF uses the name of the entity bean
>> class (that one annotated with @Entity) but it seems that is not working.
>>
>> Thanks
>> Markus
>>
>
>
>