Hi Peter,
I will try to clarify the question on Ming's behalf:
Does toplink support IdentityGenerator for generated pk values. If yes,
what is the expected DDL for running against various dbs.
Thanks,
Mitesh
Peter Krogh wrote:
> I am not sure that I fully understand your questions, but let me give
> them a shot.
>
> 1. Are the sequence name "SEQ_GEN_SEQUENCE" and its increment/initial
> values changeable for IDENTITY type PK?
> I think that this is what the SeqeunceGenerator annotation is for.
>
> 2. Is there an IdentityGenerator annotation similar to
> @SequenceGenerator? What's the usage? In case of @SequenceGenerator,
> the above values can be set in its elements. For example:
> @SequenceGenerator(name="mySequenceGenerator", sequenceName =
> "SEQ_NAME", initialValue=1, allocationSize=1)
>
> Again, I believe that the correct one to use is the
> SeqeunceGenerator. The table based sequencing is called TableGenerator.
>
> The error that you are getting is because the allocation size is set
> to 50. You must either set the increment by on your sequence to 50,
> or change the allocation size using SequenceGenerator like you
> indicated above.
>
> -----Original Message-----
> *From:* Ming Zhang [mailto:ming.zhang_at_Sun.COM]
> *Sent:* Thursday, October 20, 2005 12:38 PM
> *To:* Peter Krogh
> *Cc:* ejb3-toplink-ext_at_Sun.COM
> *Subject:* Re: Primary Key generation type IDENTITY
>
> I an using DDL. Added the "create sequence" in it:
> create table datatypes(ID INTEGER, shortData smallint, longData
> number, floatData real,
> sqldatedata date, utildatedata date, timeStampData timestamp(9),
> integerData integer,
> byteData number, booleanData number, characterData char(100),
> CONSTRAINT DATATYPES_PK PRIMARY KEY (ID));
>
> create sequence SEQ_GEN_SEQUENCE START WITH 1 INCREMENT BY 1;
>
> Now I got "increment does not match its pre-allocation size":
> Caused by: Exception [TOPLINK-7027] (Oracle TopLink Essentials -
> 10g release 4 (10.1.4.0.0) (Build 051010Dev)):
> oracle.toplink.essentials.exceptions.ValidationException
> Exception Description: The sequence named [SEQ_GEN_SEQUENCE] is
> setup incorrectly. Its increment does not match its
> pre-allocation size.
> at
> oracle.toplink.essentials.exceptions.ValidationException.sequenceSetupIncorrectly(ValidationException.java:1200)
> at
> oracle.toplink.essentials.sequencing.StandardSequence.createVector(StandardSequence.java:146)
> ...
>
> But still have following questions:
> 1. Are the sequence name "SEQ_GEN_SEQUENCE" and its
> increment/initial values changeable for IDENTITY type PK?
> 2. Is there an IdentityGenerator annotation similar to
> @SequenceGenerator? What's the usage? In case of
> @SequenceGenerator, the above values can be set in its elements.
> For example:
> @SequenceGenerator(name="mySequenceGenerator", sequenceName =
> "SEQ_NAME", initialValue=1, allocationSize=1)
>
> Thanks,
> Ming
>
>
> Peter Krogh wrote:
>
>> It appears that this sequence is not created on the DB.
>>
>> How are you creating this? Using the DDL generation? Manually?
>>
>> Check the DB and see if that sequence is created
>>
>> -----Original Message-----
>> *From:* Ming Zhang [mailto:ming.zhang_at_Sun.COM]
>> *Sent:* Wednesday, October 19, 2005 8:54 PM
>> *To:* ejb3-toplink-ext_at_Sun.COM
>> *Subject:* Primary Key generation type IDENTITY
>>
>> Hello TopLink experts,
>>
>> I have some general questions regarding the IDENTITY PK
>> generation type. How is the ID annotated in this case and is
>> there a IdentityGenerator annotation similar to
>> @SequenceGenerator annotation? What's the specific usage? How
>> do we handle these in DDL?
>>
>> I tried @Id(generate = GeneratorType.IDENTITY) in my apps and
>> was able to compile deploy. But got following exception
>> during runtime:
>> Caused by: Exception [TOPLINK-4002] (Oracle TopLink
>> Essentials - 10g release 4 (10.1.4.0.0) (Build 051010Dev)):
>> oracle.toplink.essentials.exceptions.DatabaseException
>> Internal Exception: java.sql.SQLException: [sunm][Oracle JDBC
>> Driver][Oracle]ORA-02289: *sequence does not exist*
>> Error Code: 2289
>> Call:SELECT SEQ_GEN_SEQUENCE.NEXTVAL FROM DUAL
>> Query:ValueReadQuery()
>> at
>> oracle.toplink.essentials.exceptions.DatabaseException.sqlException(DatabaseException.java:310)
>> at
>> oracle.toplink.essentials.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:550)
>> at
>> oracle.toplink.essentials.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:436)
>>
>> Thanks,
>> Ming
>>
>>
>>
>> 6f4mWKmVZd/5GiAuNBf0Rw)--
>>
>