persistence@glassfish.java.net

Re: docs about generation bean's id

From: Marina Vatkina <Marina.Vatkina_at_Sun.COM>
Date: Thu, 15 Dec 2005 12:58:37 -0800

Petr,

Generate type AUTO is work in progress, and will change eventually
to avoid having extra table when not necessary. But in any case, the
user shouldn't care much about the actual values as long as they are
unique.
In java2db case, it shouldn't happen that there is another application
which uses the same set of tables, so there is no possibility to get a
unique constraint violation.

Which constraints do you refer to for java2db? FKs?

thanks,
-marina

Petr Blaha wrote:

> Hi Marina,
> I will clarify my questions. I created an entity bean with AUTO generate
> of primary key. Then new table SEQUENCE is created and in the table is
> one row. The values are SEQ_GEN and 50.
> When, I persist the entity correct IDs are generated for this bean. The
> ids are in ascending order.
> However, when you add other bean in same persistence unit you realized
> that the SEQUENCE order is shared between both beans. It means that the
> beans id are in interchangeable order. For instance first bean has 1,3,
> .... and second one has even numbers.
>
> My questions are:
> 1) Is this sharing of the sequence correct? I guess, sequence generation
> should be uniquely for every bean, e.g. 1,2,3,... order
> 2) This sharing is for all beans in persistence unit, ejb module or app
> server?
> 3) What does the value 50 for SEQ_COUNT mean? I'm interested how the
> bean's IDs are generated.
> 4) I have filed issue #6280514 'Unique constraints aren't created when
> create table feature is enabled' for App server 8.1. Will be this issue
> resolved in Glassfish? Does the container create constraints between
> tables for java2db? I think Hiberante does it.
>
> Thanks,
> Petr
>
> Marina Vatkina wrote:
> > Petr,
> >
> > Are you looking at the values in the SEQUENCE table, or at the actual generated
> > IDs?
> >
> > thanks,
> > -marina
> >
> > Kenneth Saks wrote:
> >
> >
> >>Petr Blaha wrote:
> >>
> >>
> >>>Hi Ken,
> >>
> >>Hi Petr,
> >>
> >> I don't work on the persistence implementation :-) Marina?
> >>
> >> --ken
> >>
> >>
> >>>I'm using GeneratorType.AUTO type for Id of my bean. I know that
> >>>server is responsible for generating of new ID. I realized that new
> >>>table SEQUENCE is created and id is generated correctly for my beans.
> >>>However, ids are not in ascending order. It means that first time I
> >>>get 10 then 20,... 251 ... Why the server doesn't use 1,2,3,.....
> >>>Is this sequence table uses for all beans? For instance, I have in
> >>>SEQUENCE table these rows:
> >>>
> >>> SEQ_GEN 350
> >>> SEQ_GEN 200
> >>>
> >>>Can you point me to some docs that describe the alghoritm of this and
> >>>other type like TABLE, ....?
> >>>
> >>>Thanks,
> >>>Petr
> >
> >