Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] TableGenerator question: is the provider responsible for initializing rows?

On Tue, Aug 30, 2011 at 4:11 PM, Andrei Ilitchev <andrei.ilitchev@xxxxxxxxxx> wrote:
> Where should I file an RFE for a side-effect-free enhancement to have
> EclipseLink automatically insert rows in @TableGenerator-mentioned tables?
I would use Eclipse bugzilla
https://bugs.eclipse.org/bugs/

Thanks.

Here's a summary in case anyone else is interested:

OpenJPA is the most lenient and friendly here: it reads the initialValue() assignment of the @TableGenerator annotation, and if there is not an appropriate row in the appropriate table, it inserts a row with an initial value taken from the @TableGenerator annotation.  To my eyes this is all exactly right.  It does not attempt to create the identity table if it doesn't exist, just as it does not create any tables unless you tell it to explicitly.

EclipseLink does nothing unless eclipselink.ddl-generation is set to create-tables.  In addition to creating tables--its actual purpose--this setting appears to make EclipseLink do INSERTs into @TableGenerator-referenced sequence tables where appropriate.  I have not yet checked to see if it honors the initialValue attribute from @TableGenerators (see Hibernate, below, for why on earth I'd be concerned about this).

Hibernate as usual does the most surprising thing possible.  It tries to be friendly--it will automatically INSERT into the sequence table where appropriate--but it ignores the initialValue attribute of @TableGenerators and appears to insert 0 in all cases.  I'm going to file a bug here.

May I suggest to anyone reading who happens to be on the JPA expert committee to either standardize this or to at least make a note of it in the specification?  That would be really helpful.

It looks from all this silliness like the most portable way to do things is to insert into the table myself, and then let the JPA provider update it as necessary.  I hope they all get the updates better than they do the inserts!  :-)

Best,
Laird

--
http://about.me/lairdnelson


Back to the top