See my other post called 'Torque question' which also answers this question.

Cheers,

James

-----Original Message-----
From: James Coltman [mailto:[EMAIL PROTECTED]]
Sent: 07 June 2001 16:16
To: [EMAIL PROTECTED]
Subject: RE: Help needed with id_broker and foreign keys


This is the way in which I thought it should work. But when I try to access
the primary key after
executing the doInsert method its value is still set to null. Having stepped
through the code it would
appear that this is because the buildCriteria( Foo obj ) method in the
generated peer is setting
the primary key value to null i.e criteria.add(  FOO_ID , obj.getFooId() ).

This means that the branch:
        if (!criteria.containsKey(pk.getFullyQualifiedName()))

will return false and no key will be generated.

I also don't see that if this was not occuring, and the key was generated,
how the primary key in Foo object
would be set to the newly generated value.

As usual any help given would be much appreciated.

James

-----Original Message-----
From: jmcnally [mailto:jmcnally]On Behalf Of John McNally
Sent: 06 June 2001 18:50
To: [EMAIL PROTECTED]
Subject: Re: Help needed with id_broker and foreign keys


If you have an object Foo and you call foo.save() or use the Peer
directly and call FooPeer.doInsert(foo);  foo will then have its id set
and it is available through either getPrimaryKey() or through the
column getter ( e.g. getFooId() ).

john mcnally

James Coltman wrote:
>
> Hi,
>
> I use the id_broker to create unique id for each new row. In order to
> populate my foreign keys on other tables I need to use this newly created
> id. When you create a new row entry how do you find out the id that was
> allocated to that entry? Is the only way to do a second select to get back
> the newly created row (an id)? I assume someone must have come across this
> before. Any help would be much appreciated.
>
> James
>
> ---------------------------------------------------------------------
> 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]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to