Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Sequencing strategy and collisions

You can set the "initialValue" of a sequence TableGenerator to the current
maximum assign id if you are migrating existing data.  You could also update
the sequence table row directly using SQL to the max assigned value.  You
could continue to use IDENTITY if you wish, but in general I would not
recommend IDENETITY because you cannot pre-allocate.

JPA does not support a single row sequence table, but EclipseLink does using
its UnaryTableSequence.  With a logical sequence pre-allocation size the
sequence allocation is rarely a performance or contention issue, so I would
not be concerned with having a single table.

For more information see,


cowwoc wrote:
> Hi,
> I am migrating a database from Hibernate to EclipseLink and in the process
> the sequencing strategy has migrated from IDENTITY to AUTO under the MySQL
> database. All of a sudden I am getting ID collisions because the
> "sequence" table only contains one row ("seq_gen", maximumId) and in my
> case I've already got existing Ids larger than maximumId (which defaulted
> to zero).
> My question is:
> - How is the default sequencing mechanism supposed to avoid collisions?
> Does it simply assume that the id field will be big enough and will never
> roll over? Even if I fix maximumId to be large enough for my existing
> dataset, how does it guarantee no collisions in the future?
> - What are the benefits of a global sequence number versus per-table
> sequence number?
> - How does one get JPA to use one row per table it is sequencing? Doesn't
> this mechanism make it easier to cluster or split the database in the
> future as your business grows?
> - What is the ideal sequencing strategy in MySQL?
> Thank you,
> Gili

--- James Sutherland
 EclipseLink ,
Wiki: EclipseLink , TopLink 
Forums: TopLink , EclipseLink 
Book: Java Persistence 
View this message in context:
Sent from the EclipseLink - Users mailing list archive at

Back to the top