DB2 UDB also supports "GENERATED BY DEFAULT AS IDENTITY" columns. How can I make it 
work with OJB? 

The implementation I'm looking for is the one that leaves PK as null at the time of 
insert. I realize that it might be impossible to do in the framework that tries to 
manage object's identity even before it's inserted in database. 

Thank you.
Max.

-----Original Message-----
From: Armin Waibel [mailto:[EMAIL PROTECTED]
Sent: Thursday, July 29, 2004 10:01 AM
To: OJB Users List
Subject: Re: Negative Sequence Numbers?


Vesely, Maxim [IT] wrote:

> Does anyone know how to turn "native" sequencing in DB2? I do get -1 and -2 as 
> values for that column and at some point(when application is restarted) it 
> complaints that an attempt was made to insert non-unique primary key.
>

As far as I know DB2 support DB generated sequence keys. So you can use 
SequenceManagerNextValImpl to generate PK values. Please see

http://db.apache.org/ojb/docu/guides/sequencemanager.html#Database+sequences+based+implementation

The sequence names can be set in field-descriptor or automatic generated 
by OJB.

regards,
Armin

> Thanks in advance.
> Max.
> 
> -----Original Message-----
> From: Charles N. Harvey III [mailto:[EMAIL PROTECTED]
> Sent: Thursday, July 29, 2004 9:24 AM
> To: OJB Users List
> Subject: Re: Negative Sequence Numbers?
> 
> 
> It means that something isn't set correctly in the database.
> This has happened to me many times.  It always happens when I turn on
> "native" sequencing (IDENTITY in MSSQL or AUTOINCREMENT in MySql).  Check
> the PK of your database, it might not be properly set to increment.  
> Whenever
> this isn't set properly I get -1 and -2 for sequence numbers all the time.
> 
> Although, I might be completely wrong and it might be something totally
> different, I thought I'd try though.
> 
> 
> Charlie
> 
> 
> 
> Vesely, Maxim [IT] said the following on 7/29/2004 9:11 AM:
> 
> 
>>I experienced exactly the same problem running in managed environment with JTA 
>>transaction.
>>
>>Max.
>>
>>-----Original Message-----
>>From: Armin Waibel [mailto:[EMAIL PROTECTED]
>>Sent: Thursday, July 29, 2004 8:35 AM
>>To: OJB Users List
>>Subject: Re: Negative Sequence Numbers?
>>
>>
>>Robert Crawford wrote:
>>
>> 
>>
>>
>>>Armin Waibel said:
>>>
>>>   
>>>
>>>
>>>>Robert Crawford wrote:
>>>>
>>>>
>>>>     
>>>>
>>>>
>>>>>Armin Waibel said:
>>>>>
>>>>>
>>>>>       
>>>>>
>>>>>
>>>>>>Do you only use the PB-api? This bug is odmg-api related.
>>>>>>         
>>>>>>
>>>>>
>>>>>I only use the PB-api.
>>>>>
>>>>>       
>>>>>
>>>>
>>>>Then you shouldn't get problems with negative sequence numbers.
>>>>Can you describe me with some pseudo code an test case to reproduce your
>>>>problem?
>>>>     
>>>>
>>>
>>>   
>>>
>>
>>Don't you use transaction demarcation or is this code snip from an 
>>managed environment with JTA transaction?
>>
>>Armin
>>
>> 
>>
>>
>>>>>From memory, the code looks something like this:
>>>
>>>PersistenceBroker broker =
>>>PersistenceBrokerFactory.createPersistenceBroker(pbKey);
>>>User user = new User();
>>>user.setEmailAddress(emailAddress);
>>>// more setters here, nothing that touches the primary key
>>>broker.store(user);
>>>
>>>At this point the database has a negative number for the primary key and,
>>
>>>from what I can recall from my debugging, the user object has zero in the
>>
>>>primary key field.
>>>
>>>Here's the start of the class descriptor:
>>>
>>><class-descriptor
>>>   class="com.kloognome.accesscontrol.ojb.UserInstance"
>>>   table="ac_users">
>>>   <field-descriptor name="userNbr" column="user_nbr" jdbc-type="INTEGER"
>>>primarykey="true" autoincrement="true" access="readonly"/>
>>>
>>>
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: [EMAIL PROTECTED]
>>>For additional commands, e-mail: [EMAIL PROTECTED]
>>>
>>>
>>>
>>>   
>>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: [EMAIL PROTECTED]
>>For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: [EMAIL PROTECTED]
>>For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>>
>> 
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to