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" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > 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" <[EMAIL PROTECTED]> > > To: <[EMAIL PROTECTED]> > > 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" <[EMAIL PROTECTED]> > > > To: <[EMAIL PROTECTED]> > > > 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" <[EMAIL PROTECTED]> > > > > To: <[EMAIL PROTECTED]> > > > > 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: [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]
