openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Garimella Srinivas <>
Subject Re: Id generation - regarding
Date Fri, 02 Apr 2010 03:12:31 GMT
Thank you for immediate reply. Checked the pointers. I am using Derby which does not support
Sequencing yet. However I got the required result by changing athe allocation size to 1.

G Srinivas

--- On Thu, 4/1/10, No1UNo <> wrote:

From: No1UNo <>
Subject: Re: Id generation - regarding
Date: Thursday, April 1, 2010, 4:44 PM

This is more or less what you'd expect.  The TableGenerator is preallocating a block of 'allocationSize'
which is 100 in your case.  Requesting several IDs should give sequential results when requested
from one EntityManager.  Starting the application and restarting will result in another allocation.

The result is that your IDs will not be sequential.  This may not meet your initial expectations
but is entirely fine.

An alternative is to use a sequence generator if your database supports it.

You might find that this [1] article at Wikibooks provides a good explanation.

[1] http:

On Apr 1, 2010, at 4:56 AM, Garimella Srinivas [via OpenJPA] wrote:

> I have an entity PhoneNo with @id as follows 
> @Id 
>  @TableGenerator(name="PhoneBook_IDGen", table="ID_GEN_TABLE",       pkColumnName="Gen_Name",
valueColumnName="Gen_ID_Value", pkColumnValue="PhoneBook_IDGen", initialValue = 1, allocationSize
= 100)   
> @GeneratedValue(strategy=GenerationType.TABLE,generator = "PhoneBook_IDGen") 
>     public long getId() { 
>         return; 
>     } 
> Every time the server/openjpa is started  the id table is updated  and the id starts
with an icrement of 100. If I have 2 asthe last id id for first run the second run starts
with 100. 
> However the the id needs to be 3 for the next entity. Is some thing wrong? 
> Thanks 
> G Srinivas 
> View message @ 
> To start a new topic under OpenJPA Users, email

> To unsubscribe from OpenJPA Users, click here.

View this message in context:
Sent from the OpenJPA Users mailing list archive at

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message