[Opensource] Value of last inserted auto-generated key.

Michael Rimov rimovm at centercomp.com
Wed Jun 12 21:32:36 PDT 2002


At 08:32 PM 6/11/2002 -0700, you wrote:

>  Hi,
>
>     Presently I am using dbobj for adding records inside a table in which 
> a column value is automatically generated by the database. Once I insert 
> the record, how  I can get the value of last inserted autogenerated 
> column considering that the other half (exluding that column)of the table 
> is not unique. As I think, In a multithread enviornment I can achieve it 
> either by creating a transaction block  at the dbobject level or using a 
> synchronized method at the application level that involves insertion 
> using dbobjects.

Sounds good so far.


>Now questions are -
>
>1. Is there any other way to achieve it?

Not that I'm aware of.  Adam R. or Peter P (I don't remember which) created 
a DBSequence class that made use of such auto-types for I think it was 
PostgreSQL, but I don't know if that has in it the guts you're looking for.



>2. Does dbobject provide the Transaction Block kind of mechanism?

You can use JDBC transactions by grabbing the DBConnection itself, and 
feeding it to your DBObjects.  You can use the setAutoCommit() so you can 
get what you're looking for.  Then call commit against the DBConnection.

HTH!
                                                 -Mike




More information about the Opensource mailing list