users@glassfish.java.net

Re: JPA: how to configure default sequencer?

From: Witold Szczerba <pljosh.mail_at_gmail.com>
Date: Thu, 22 Mar 2007 23:58:48 +0100

Hmm, in our case GenerationType.AUTO uses sequencer in TopLink and Hibernate.
I know this, because in database, there is "SEQ_GEN_SEQUENCE" that is
altered by TopLink each time it adds new entity and
"HIBERNATE_SEQUENCE" used by Hibernate.
Both TopLink and Hibernate use only one sequencer for every table.
I could change GenerationType.AUTO into .SEQUENCE using some tool to
automate this, but I would like not to specify sequencer name entity
by entity, I would rather use some global setting for sequencer.
Does orm.xml allows global settings to be used by every entity
GenerationType annotation?


2007/3/22, Marina Vatkina <Marina.Vatkina_at_sun.com>:
> Hi Witold,
>
> Bad news: the spec allows (unfortunately IMHO) to treat GenerationType.AUTO in
> any way a provider wants and TopLink Essentials uses table-based generation for
> this setting.
>
> Good news: You should be able to override the @GeneratedValue annotation using
> orm.xml's that use partial overrides.
>
> Regards,
> -marina
>
> Witold Szczerba wrote:
> > Hello there,
> > is there some way to tell JPA provider which sequencer should be taken
> > by default when generating identity fields?
> >
> > Here is an example of my @Entity class:
> >
> > @Entity
> > public class Loan {
> >
> > @Id
> > @GeneratedValue(strategy = GenerationType.AUTO)
> > private Long id;
> >
> > @Version
> > private long version;
> >
> > ...........
> > ...........
> > }
> >
> > In my company, we use Hibernate for importing large amount of data,
> > because TopLink Essentials has memory leaks (tested on Glassfish 9.0)
> > which eventually causes JVM to throw OutOfmemoryException. I know, we
> > should try Glassfish 9.1, but both GF9.1 and NetBeans 5.5.1 are still
> > in beta.
> >
> > The problem is that Hibernate and TopLink are using different default
> > sequencers in our database (this is Oracle XE). When import (it is
> > performed by separate EJB module) is done, when we start using our
> > application core module, TopLink is creating new entities using
> > different sequencer.
> >
> > I am worrying that we will have to re-factor every @Entity's
> > @GeneratedValue annotation (we have many, many....many entities)
> > setting explicitly the sequencer name, but I would like to know if
> > there is some other way, so by default Hibernate and Toplink would use
> > exactly the same sequencer for every @Entity...
> >
> > Thanks in advance,
> > W.Sz.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> > For additional commands, e-mail: users-help_at_glassfish.dev.java.net
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>