You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by "nntp://news.gmane.org/gmane.group.name" <r1...@in.ibm.com> on 2003/09/05 17:41:52 UTC

More on Identity columns in db/2

I came back to this topic again and realised that INSERT statements in OJB
are always
trying to send the PK column also in the query.
That being the case, How do we use "SequenceManagerNativeImpl" ?
The two dbs that I know (SQLServer and db/2) do not allow u to pass the
value for an Identity Column in SQL statement.
Am I missing some thing ?

TIA
akhil


"Akhil Kumar" <r1...@in.ibm.com> wrote in message
news:OF88572F82.137C53AB-ON65256D8D.003F469C@in.ibm.com...
>
>
>
>
> Hi,
> This is a response to #OJB201...
> (http://scarab.werken.com/issues/id/OJB201)
> I had spent some time earlier on the approach suggested in this issue but
> did not post it for the reason documented below
> I thaught it'll be better that others also understand the implications (of
> Identity Column based SeqMgr )
>
> Platform.getLastInsertIdentity() should not be implemented as described in
> the defect !
>
> The db/2 scalar function 'identity_val_local() ' does not take any
> parameter...
> it is supposed to return the value of last identity column that was
> incremented !
> The reporter of the defect has recommended using
> "select identity_val_local() from <tableName> fetch first ro only"
> however the above SQL has nothing to do with the <tableName>..
>
> running it is as good as running: "values identity_val_local()" which does
> not take any table name.
> and it can make the usage of "values identity_val_local()" : potentially
> dangerous:
> in the following scenario:
>
> -Table T1 uses Identity column (and used in O-R mapping)
> -A Trigger is defined for INSERTS in T1 which inserts a record in T2 (T2
> has nothing to do with OR business)
>       (such approaches are there in many systems e.g. automatically
> calculating summaries etc)
> -both T1 and T2 use Identity columns.
> -OJB inserts a record in T1 which leads to another record getting added to
> T2
> -"values identity_val_local()" will return the value of  identity column
in
> T2 and not T1, as required by the native based SeqMgr.
>
> thanks
> akhil




---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: More on Identity columns in db/2

Posted by Michael Becke <be...@u.washington.edu>.
Hi Akhil,

You have to specify the identity column as read-only.  You can do this 
by adding 'access="readonly"' to the field descriptor.

Mike

nntp://news.gmane.org/gmane.group.name wrote:

> I came back to this topic again and realised that INSERT statements in OJB
> are always
> trying to send the PK column also in the query.
> That being the case, How do we use "SequenceManagerNativeImpl" ?
> The two dbs that I know (SQLServer and db/2) do not allow u to pass the
> value for an Identity Column in SQL statement.
> Am I missing some thing ?
> 
> TIA
> akhil
> 
> 
> "Akhil Kumar" <r1...@in.ibm.com> wrote in message
> news:OF88572F82.137C53AB-ON65256D8D.003F469C@in.ibm.com...
> 
>>
>>
>>
>>Hi,
>>This is a response to #OJB201...
>>(http://scarab.werken.com/issues/id/OJB201)
>>I had spent some time earlier on the approach suggested in this issue but
>>did not post it for the reason documented below
>>I thaught it'll be better that others also understand the implications (of
>>Identity Column based SeqMgr )
>>
>>Platform.getLastInsertIdentity() should not be implemented as described in
>>the defect !
>>
>>The db/2 scalar function 'identity_val_local() ' does not take any
>>parameter...
>>it is supposed to return the value of last identity column that was
>>incremented !
>>The reporter of the defect has recommended using
>>"select identity_val_local() from <tableName> fetch first ro only"
>>however the above SQL has nothing to do with the <tableName>..
>>
>>running it is as good as running: "values identity_val_local()" which does
>>not take any table name.
>>and it can make the usage of "values identity_val_local()" : potentially
>>dangerous:
>>in the following scenario:
>>
>>-Table T1 uses Identity column (and used in O-R mapping)
>>-A Trigger is defined for INSERTS in T1 which inserts a record in T2 (T2
>>has nothing to do with OR business)
>>      (such approaches are there in many systems e.g. automatically
>>calculating summaries etc)
>>-both T1 and T2 use Identity columns.
>>-OJB inserts a record in T1 which leads to another record getting added to
>>T2
>>-"values identity_val_local()" will return the value of  identity column
> 
> in
> 
>>T2 and not T1, as required by the native based SeqMgr.
>>
>>thanks
>>akhil
> 
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org