openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Dick <michael.d.d...@gmail.com>
Subject Re: @SequenceGenerator allocationSize
Date Wed, 08 Jul 2009 01:54:01 GMT
Hi Emmanuel,

The scenario you've described shouldn't happen.

When you create the first EntityManager it will reserve the next 10 values
from your sequence generator (1 through 10). The second EntityManager gets
the next 10 values (11 through 20). This call to reserve sequence values
from the database is atomic and you should never see two EMs using the same
sequence value.

I've only tried this with PostgreSQL but it looks like it's working for me.

Do you have a testcase that shows the behavior you've described?

-mike

On Mon, Jul 6, 2009 at 4:23 AM, emmanuel2009 <clarkemmanuel2009@gmail.com>wrote:

>
> Hi guys,
>
>     I got some doubts in allocationSize. My project is a multi-application
> environment. I'm giving SequenceGenerator with allocationSize=10.
>
> @Id
> @GeneratedValue(strategy=GenerationType.SEQUENCE,generator="myseq")
> @SequenceGenerator(name="myseq",sequenceName="MY_SEQ",allocationSize=10)
> private long id;
>
> Suppose my first application say app1 will access the DB and got 10
> available id's. My second application say aap2 will also get same id. when
> app1 will insert it insert id 100 by the time app2 will insert it also
> tries
> to insert 100. it will cause problem.
>
> What is the use of allocationSize then.
>
>
> --
> View this message in context:
> http://n2.nabble.com/%40SequenceGenerator-allocationSize-tp3212122p3212122.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>

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