users@glassfish.java.net

JPA: how to configure default sequencer?

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

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.