You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by Scott Eade <se...@backstagetech.com.au> on 2001/12/06 23:53:11 UTC

Re: Copying and then saving a row into DB, how do I get the primary key

----- Original Message -----
From: "Pugh, Eric" <EP...@MuseumCompany.com>
> Hi all,
>
> I looked through the archives to find the answer, b/c I swear I saw the
> answer, but no luck...
>
> I am using MSSQL as my database, and all my tables are set with
> idMethod=none, using Turbine 2.1.
>
> I want to copy a product object with product id 2.   So I do:
> productB = productA.copy();

Try adding this:

    productB.setNew(true);

> productB.save();
>
> This saves my new row in the database, but my productB's primary key is
> null.  I used profiler and see the we are doing an insert, but there
doesn't
> be anything like return @@Identity or anything to pass back what my new
> primary key is.
>
> Is the only way of figuring what productB's primary key is to do a select
> max(product_id) on my products table?
>
> Eric

HTH.

Scott



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>