You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by pa...@bt.com on 2001/10/15 14:37:52 UTC

object.save()

Can anybody tell me if calling save() on a new object sets the primary key
id of the object, so that I can say getPrimaryKey() after calling save.
The reason being I need the PK of the newly created object after calling
save and I know doInsert on the objectPeer class returns the PK but I can't
seem to work out if the save method sets the PK?

I want to say 
object.save();  /*object does not have the primary key set as I am using an
auto increment*/
pk = object.getPrimaryKey();

Cheers

Paul

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


Re: object.save()

Posted by Dan Bachelder <ch...@chowda.net>.
I'd been using both for quite some time.. why use an arrow when you can use
a nuke right? anyway, I hadn't needed the key back until tonight which is
the only reason this has come to light... in any case, it works with both...
thanks

----- Original Message -----
From: "Scott Eade" <se...@backstagetech.com.au>
To: <tu...@jakarta.apache.org>
Sent: Sunday, October 28, 2001 12:09 AM
Subject: Re: object.save()


> It's sort of odd that it lets you do both.  I would have thought setNew()
> would clear the modified flag and setModified() would clear the new flag.
> Then if you invoke save() on a new record with the modified flag set an
> exception ought to be thrown (due to the fact that no key value is set).
>
> I haven't looked at the source, but this would make sense to me.
>
> Scott
>
> ----- Original Message -----
> From: "Dan Bachelder" <ch...@chowda.net>
> To: <tu...@jakarta.apache.org>
> Sent: Sunday, October 28, 2001 2:28 PM
> Subject: Re: object.save()
>
>
> > ouch... good call.. why was I doing that? I'm pleading temporary
> insanity...
> >
> >
> >
> > ----- Original Message -----
> > From: "Scott Eade" <se...@backstagetech.com.au>
> > To: <tu...@jakarta.apache.org>
> > Sent: Saturday, October 27, 2001 11:24 PM
> > Subject: Re: object.save()
> >
> >
> > > Dan,
> > >
> > > Don't do this:
> > > >                 contact.setModified(true);
> > > and see what happens.
> > >
> > > Scott
> > >
> > > ----- Original Message -----
> > > From: "Dan Bachelder" <ch...@chowda.net>
> > > To: <tu...@jakarta.apache.org>
> > > Sent: Sunday, October 28, 2001 2:02 PM
> > > Subject: Re: object.save()
> > >
> > >
> > > > I am not seeing this behavior... after:
> > > >
> > > >                 Contact contact = new Contact();
> > > >                 data.getParameters().setProperties(contact);
> > > >                 contact.setModified(true);
> > > >                 contact.setNew(true);
> > > >                 contact.save();
> > > >                 logDebug("inserted contact with key: " +
> > > > contact.getContactId());
> > > >
> > > > I am seeing null as the key... but I confirm that the data is being
> > > inserted
> > > > into the database with an auto generated key.. this is with the
> > TDK2.1...
> > > I
> > > > see how I can change the OM generation templates to return the key,
> but
> > it
> > > > seems like this must be something someone is doing with the TDK
> > already..
> > > > how are you doing it?
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
>
>


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


Re: object.save()

Posted by Dan Bachelder <ch...@chowda.net>.
yes I am only using thing.getKeyName()

Hopefully when I get these features done, I'll have time to figure out why I
need both...

----- Original Message -----
From: "Heiko Braun" <he...@fork.de>
To: <tu...@jakarta.apache.org>
Sent: Sunday, October 28, 2001 12:16 PM
Subject: Re: object.save()


>
> That's weired,
> i am using the setNew(true) without calling
> setModified() and it all works fine with new objects.
>
> Did you try to access the key by its name
> instead of using the getPrimaryKey() method?
>
>  --
>  heiko braun, fork unstable media
>  http://www.unstablemedia.com
>
>
> On Sun, 28 Oct 2001, Dan Bachelder wrote:
>
> > After working with a few more of my objects and needing this same
behavior,
> > I have noticed that it is not consistent.. working from a clean DB, I
have
> > some objects that will not give you the system generated key after an
insert
> > unless you specify both new and modified as true.... out of three
objects so
> > far only one needed new to be true and modified to be false... the other
two
> > needed both to be true to get back the key... I have not had a chance to
dig
> > through and discover why yet...
> >
> > ----- Original Message -----
> > From: "Scott Eade" <se...@backstagetech.com.au>
> > To: <tu...@jakarta.apache.org>
> > Sent: Sunday, October 28, 2001 12:09 AM
> > Subject: Re: object.save()
> >
> >
> > > It's sort of odd that it lets you do both.  I would have thought
setNew()
> > > would clear the modified flag and setModified() would clear the new
flag.
> > > Then if you invoke save() on a new record with the modified flag set
an
> > > exception ought to be thrown (due to the fact that no key value is
set).
> > >
> > > I haven't looked at the source, but this would make sense to me.
> > >
> > > Scott
> > >
> > > ----- Original Message -----
> > > From: "Dan Bachelder" <ch...@chowda.net>
> > > To: <tu...@jakarta.apache.org>
> > > Sent: Sunday, October 28, 2001 2:28 PM
> > > Subject: Re: object.save()
> > >
> > >
> > > > ouch... good call.. why was I doing that? I'm pleading temporary
> > > insanity...
> > > >
> > > >
> > > >
> > > > ----- Original Message -----
> > > > From: "Scott Eade" <se...@backstagetech.com.au>
> > > > To: <tu...@jakarta.apache.org>
> > > > Sent: Saturday, October 27, 2001 11:24 PM
> > > > Subject: Re: object.save()
> > > >
> > > >
> > > > > Dan,
> > > > >
> > > > > Don't do this:
> > > > > >                 contact.setModified(true);
> > > > > and see what happens.
> > > > >
> > > > > Scott
> > > > >
> > > > > ----- Original Message -----
> > > > > From: "Dan Bachelder" <ch...@chowda.net>
> > > > > To: <tu...@jakarta.apache.org>
> > > > > Sent: Sunday, October 28, 2001 2:02 PM
> > > > > Subject: Re: object.save()
> > > > >
> > > > >
> > > > > > I am not seeing this behavior... after:
> > > > > >
> > > > > >                 Contact contact = new Contact();
> > > > > >                 data.getParameters().setProperties(contact);
> > > > > >                 contact.setModified(true);
> > > > > >                 contact.setNew(true);
> > > > > >                 contact.save();
> > > > > >                 logDebug("inserted contact with key: " +
> > > > > > contact.getContactId());
> > > > > >
> > > > > > I am seeing null as the key... but I confirm that the data is
being
> > > > > inserted
> > > > > > into the database with an auto generated key.. this is with the
> > > > TDK2.1...
> > > > > I
> > > > > > see how I can change the OM generation templates to return the
key,
> > > but
> > > > it
> > > > > > seems like this must be something someone is doing with the TDK
> > > > already..
> > > > > > how are you doing it?
> > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: turbine-user-help@jakarta.apache.org
> > >
> > >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: turbine-user-help@jakarta.apache.org
> >
> >
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
>
>


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


Re: object.save()

Posted by Heiko Braun <he...@fork.de>.
That's weired,
i am using the setNew(true) without calling
setModified() and it all works fine with new objects.

Did you try to access the key by its name
instead of using the getPrimaryKey() method?

 --
 heiko braun, fork unstable media
 http://www.unstablemedia.com


On Sun, 28 Oct 2001, Dan Bachelder wrote:

> After working with a few more of my objects and needing this same behavior,
> I have noticed that it is not consistent.. working from a clean DB, I have
> some objects that will not give you the system generated key after an insert
> unless you specify both new and modified as true.... out of three objects so
> far only one needed new to be true and modified to be false... the other two
> needed both to be true to get back the key... I have not had a chance to dig
> through and discover why yet...
>
> ----- Original Message -----
> From: "Scott Eade" <se...@backstagetech.com.au>
> To: <tu...@jakarta.apache.org>
> Sent: Sunday, October 28, 2001 12:09 AM
> Subject: Re: object.save()
>
>
> > It's sort of odd that it lets you do both.  I would have thought setNew()
> > would clear the modified flag and setModified() would clear the new flag.
> > Then if you invoke save() on a new record with the modified flag set an
> > exception ought to be thrown (due to the fact that no key value is set).
> >
> > I haven't looked at the source, but this would make sense to me.
> >
> > Scott
> >
> > ----- Original Message -----
> > From: "Dan Bachelder" <ch...@chowda.net>
> > To: <tu...@jakarta.apache.org>
> > Sent: Sunday, October 28, 2001 2:28 PM
> > Subject: Re: object.save()
> >
> >
> > > ouch... good call.. why was I doing that? I'm pleading temporary
> > insanity...
> > >
> > >
> > >
> > > ----- Original Message -----
> > > From: "Scott Eade" <se...@backstagetech.com.au>
> > > To: <tu...@jakarta.apache.org>
> > > Sent: Saturday, October 27, 2001 11:24 PM
> > > Subject: Re: object.save()
> > >
> > >
> > > > Dan,
> > > >
> > > > Don't do this:
> > > > >                 contact.setModified(true);
> > > > and see what happens.
> > > >
> > > > Scott
> > > >
> > > > ----- Original Message -----
> > > > From: "Dan Bachelder" <ch...@chowda.net>
> > > > To: <tu...@jakarta.apache.org>
> > > > Sent: Sunday, October 28, 2001 2:02 PM
> > > > Subject: Re: object.save()
> > > >
> > > >
> > > > > I am not seeing this behavior... after:
> > > > >
> > > > >                 Contact contact = new Contact();
> > > > >                 data.getParameters().setProperties(contact);
> > > > >                 contact.setModified(true);
> > > > >                 contact.setNew(true);
> > > > >                 contact.save();
> > > > >                 logDebug("inserted contact with key: " +
> > > > > contact.getContactId());
> > > > >
> > > > > I am seeing null as the key... but I confirm that the data is being
> > > > inserted
> > > > > into the database with an auto generated key.. this is with the
> > > TDK2.1...
> > > > I
> > > > > see how I can change the OM generation templates to return the key,
> > but
> > > it
> > > > > seems like this must be something someone is doing with the TDK
> > > already..
> > > > > how are you doing it?
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: turbine-user-help@jakarta.apache.org
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
>
>




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


Re: object.save()

Posted by Dan Bachelder <ch...@chowda.net>.
After working with a few more of my objects and needing this same behavior,
I have noticed that it is not consistent.. working from a clean DB, I have
some objects that will not give you the system generated key after an insert
unless you specify both new and modified as true.... out of three objects so
far only one needed new to be true and modified to be false... the other two
needed both to be true to get back the key... I have not had a chance to dig
through and discover why yet...

----- Original Message -----
From: "Scott Eade" <se...@backstagetech.com.au>
To: <tu...@jakarta.apache.org>
Sent: Sunday, October 28, 2001 12:09 AM
Subject: Re: object.save()


> It's sort of odd that it lets you do both.  I would have thought setNew()
> would clear the modified flag and setModified() would clear the new flag.
> Then if you invoke save() on a new record with the modified flag set an
> exception ought to be thrown (due to the fact that no key value is set).
>
> I haven't looked at the source, but this would make sense to me.
>
> Scott
>
> ----- Original Message -----
> From: "Dan Bachelder" <ch...@chowda.net>
> To: <tu...@jakarta.apache.org>
> Sent: Sunday, October 28, 2001 2:28 PM
> Subject: Re: object.save()
>
>
> > ouch... good call.. why was I doing that? I'm pleading temporary
> insanity...
> >
> >
> >
> > ----- Original Message -----
> > From: "Scott Eade" <se...@backstagetech.com.au>
> > To: <tu...@jakarta.apache.org>
> > Sent: Saturday, October 27, 2001 11:24 PM
> > Subject: Re: object.save()
> >
> >
> > > Dan,
> > >
> > > Don't do this:
> > > >                 contact.setModified(true);
> > > and see what happens.
> > >
> > > Scott
> > >
> > > ----- Original Message -----
> > > From: "Dan Bachelder" <ch...@chowda.net>
> > > To: <tu...@jakarta.apache.org>
> > > Sent: Sunday, October 28, 2001 2:02 PM
> > > Subject: Re: object.save()
> > >
> > >
> > > > I am not seeing this behavior... after:
> > > >
> > > >                 Contact contact = new Contact();
> > > >                 data.getParameters().setProperties(contact);
> > > >                 contact.setModified(true);
> > > >                 contact.setNew(true);
> > > >                 contact.save();
> > > >                 logDebug("inserted contact with key: " +
> > > > contact.getContactId());
> > > >
> > > > I am seeing null as the key... but I confirm that the data is being
> > > inserted
> > > > into the database with an auto generated key.. this is with the
> > TDK2.1...
> > > I
> > > > see how I can change the OM generation templates to return the key,
> but
> > it
> > > > seems like this must be something someone is doing with the TDK
> > already..
> > > > how are you doing it?
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
>
>


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


Re: object.save()

Posted by Scott Eade <se...@backstagetech.com.au>.
It's sort of odd that it lets you do both.  I would have thought setNew()
would clear the modified flag and setModified() would clear the new flag.
Then if you invoke save() on a new record with the modified flag set an
exception ought to be thrown (due to the fact that no key value is set).

I haven't looked at the source, but this would make sense to me.

Scott

----- Original Message -----
From: "Dan Bachelder" <ch...@chowda.net>
To: <tu...@jakarta.apache.org>
Sent: Sunday, October 28, 2001 2:28 PM
Subject: Re: object.save()


> ouch... good call.. why was I doing that? I'm pleading temporary
insanity...
>
>
>
> ----- Original Message -----
> From: "Scott Eade" <se...@backstagetech.com.au>
> To: <tu...@jakarta.apache.org>
> Sent: Saturday, October 27, 2001 11:24 PM
> Subject: Re: object.save()
>
>
> > Dan,
> >
> > Don't do this:
> > >                 contact.setModified(true);
> > and see what happens.
> >
> > Scott
> >
> > ----- Original Message -----
> > From: "Dan Bachelder" <ch...@chowda.net>
> > To: <tu...@jakarta.apache.org>
> > Sent: Sunday, October 28, 2001 2:02 PM
> > Subject: Re: object.save()
> >
> >
> > > I am not seeing this behavior... after:
> > >
> > >                 Contact contact = new Contact();
> > >                 data.getParameters().setProperties(contact);
> > >                 contact.setModified(true);
> > >                 contact.setNew(true);
> > >                 contact.save();
> > >                 logDebug("inserted contact with key: " +
> > > contact.getContactId());
> > >
> > > I am seeing null as the key... but I confirm that the data is being
> > inserted
> > > into the database with an auto generated key.. this is with the
> TDK2.1...
> > I
> > > see how I can change the OM generation templates to return the key,
but
> it
> > > seems like this must be something someone is doing with the TDK
> already..
> > > how are you doing it?



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


Re: object.save()

Posted by Dan Bachelder <ch...@chowda.net>.
ouch... good call.. why was I doing that? I'm pleading temporary insanity...



----- Original Message -----
From: "Scott Eade" <se...@backstagetech.com.au>
To: <tu...@jakarta.apache.org>
Sent: Saturday, October 27, 2001 11:24 PM
Subject: Re: object.save()


> Dan,
>
> Don't do this:
> >                 contact.setModified(true);
> and see what happens.
>
> Scott
>
> ----- Original Message -----
> From: "Dan Bachelder" <ch...@chowda.net>
> To: <tu...@jakarta.apache.org>
> Sent: Sunday, October 28, 2001 2:02 PM
> Subject: Re: object.save()
>
>
> > I am not seeing this behavior... after:
> >
> >                 Contact contact = new Contact();
> >                 data.getParameters().setProperties(contact);
> >                 contact.setModified(true);
> >                 contact.setNew(true);
> >                 contact.save();
> >                 logDebug("inserted contact with key: " +
> > contact.getContactId());
> >
> > I am seeing null as the key... but I confirm that the data is being
> inserted
> > into the database with an auto generated key.. this is with the
TDK2.1...
> I
> > see how I can change the OM generation templates to return the key, but
it
> > seems like this must be something someone is doing with the TDK
already..
> > how are you doing it?
> >
> > ----- Original Message -----
> > From: "Heiko Braun" <he...@fork.de>
> > To: <tu...@jakarta.apache.org>
> > Sent: Monday, October 15, 2001 12:24 PM
> > Subject: Re: object.save()
> >
> >
> > >
> > > yup, thats the way it should work.
> > > i didnt try it through getPrimaryKey(),
> > > but with a specific key. (like getFooId())
> > >
> > >
> > >  --
> > >  heiko braun, fork unstable media
> > >  http://www.unstablemedia.com
> > >
> > >
> > > On Mon, 15 Oct 2001 paul.hunter@bt.com wrote:
> > >
> > > > Can anybody tell me if calling save() on a new object sets the
primary
> > key
> > > > id of the object, so that I can say getPrimaryKey() after calling
> save.
> > > > The reason being I need the PK of the newly created object after
> calling
> > > > save and I know doInsert on the objectPeer class returns the PK but
I
> > can't
> > > > seem to work out if the save method sets the PK?
> > > >
> > > > I want to say
> > > > object.save();  /*object does not have the primary key set as I am
> using
> > an
> > > > auto increment*/
> > > > pk = object.getPrimaryKey();
> > > >
> > > > Cheers
> > > >
> > > > Paul
> > > >
> > >
> ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> > > > For additional commands, e-mail:
turbine-user-help@jakarta.apache.org
> > > >
> > > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: turbine-user-help@jakarta.apache.org
> > >
> > >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: turbine-user-help@jakarta.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
>
>


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


Re: object.save()

Posted by Scott Eade <se...@backstagetech.com.au>.
Dan,

Don't do this:
>                 contact.setModified(true);
and see what happens.

Scott

----- Original Message -----
From: "Dan Bachelder" <ch...@chowda.net>
To: <tu...@jakarta.apache.org>
Sent: Sunday, October 28, 2001 2:02 PM
Subject: Re: object.save()


> I am not seeing this behavior... after:
>
>                 Contact contact = new Contact();
>                 data.getParameters().setProperties(contact);
>                 contact.setModified(true);
>                 contact.setNew(true);
>                 contact.save();
>                 logDebug("inserted contact with key: " +
> contact.getContactId());
>
> I am seeing null as the key... but I confirm that the data is being
inserted
> into the database with an auto generated key.. this is with the TDK2.1...
I
> see how I can change the OM generation templates to return the key, but it
> seems like this must be something someone is doing with the TDK already..
> how are you doing it?
>
> ----- Original Message -----
> From: "Heiko Braun" <he...@fork.de>
> To: <tu...@jakarta.apache.org>
> Sent: Monday, October 15, 2001 12:24 PM
> Subject: Re: object.save()
>
>
> >
> > yup, thats the way it should work.
> > i didnt try it through getPrimaryKey(),
> > but with a specific key. (like getFooId())
> >
> >
> >  --
> >  heiko braun, fork unstable media
> >  http://www.unstablemedia.com
> >
> >
> > On Mon, 15 Oct 2001 paul.hunter@bt.com wrote:
> >
> > > Can anybody tell me if calling save() on a new object sets the primary
> key
> > > id of the object, so that I can say getPrimaryKey() after calling
save.
> > > The reason being I need the PK of the newly created object after
calling
> > > save and I know doInsert on the objectPeer class returns the PK but I
> can't
> > > seem to work out if the save method sets the PK?
> > >
> > > I want to say
> > > object.save();  /*object does not have the primary key set as I am
using
> an
> > > auto increment*/
> > > pk = object.getPrimaryKey();
> > >
> > > Cheers
> > >
> > > Paul
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: turbine-user-help@jakarta.apache.org
> > >
> > >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: turbine-user-help@jakarta.apache.org
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
>


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


Re: object.save()

Posted by Dan Bachelder <ch...@chowda.net>.
I am not seeing this behavior... after:

                Contact contact = new Contact();
                data.getParameters().setProperties(contact);
                contact.setModified(true);
                contact.setNew(true);
                contact.save();
                logDebug("inserted contact with key: " +
contact.getContactId());

I am seeing null as the key... but I confirm that the data is being inserted
into the database with an auto generated key.. this is with the TDK2.1... I
see how I can change the OM generation templates to return the key, but it
seems like this must be something someone is doing with the TDK already..
how are you doing it?

----- Original Message -----
From: "Heiko Braun" <he...@fork.de>
To: <tu...@jakarta.apache.org>
Sent: Monday, October 15, 2001 12:24 PM
Subject: Re: object.save()


>
> yup, thats the way it should work.
> i didnt try it through getPrimaryKey(),
> but with a specific key. (like getFooId())
>
>
>  --
>  heiko braun, fork unstable media
>  http://www.unstablemedia.com
>
>
> On Mon, 15 Oct 2001 paul.hunter@bt.com wrote:
>
> > Can anybody tell me if calling save() on a new object sets the primary
key
> > id of the object, so that I can say getPrimaryKey() after calling save.
> > The reason being I need the PK of the newly created object after calling
> > save and I know doInsert on the objectPeer class returns the PK but I
can't
> > seem to work out if the save method sets the PK?
> >
> > I want to say
> > object.save();  /*object does not have the primary key set as I am using
an
> > auto increment*/
> > pk = object.getPrimaryKey();
> >
> > Cheers
> >
> > Paul
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: turbine-user-help@jakarta.apache.org
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
>
>


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


Re: object.save()

Posted by Heiko Braun <he...@fork.de>.
yup, thats the way it should work.
i didnt try it through getPrimaryKey(),
but with a specific key. (like getFooId())


 --
 heiko braun, fork unstable media
 http://www.unstablemedia.com


On Mon, 15 Oct 2001 paul.hunter@bt.com wrote:

> Can anybody tell me if calling save() on a new object sets the primary key
> id of the object, so that I can say getPrimaryKey() after calling save.
> The reason being I need the PK of the newly created object after calling
> save and I know doInsert on the objectPeer class returns the PK but I can't
> seem to work out if the save method sets the PK?
>
> I want to say
> object.save();  /*object does not have the primary key set as I am using an
> auto increment*/
> pk = object.getPrimaryKey();
>
> Cheers
>
> Paul
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
>
>


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