Byron Foster wrote:
> 
> Hello,
> 
>       First I have to say what an excellent package Torque is along with
> the other tools in Turbine.  Congrats to the people who have worked on
> it, absolutely superior work!  As someone who has worked serveral year
> with java and databases this really is a next generation tool. Along
> with Velocity for web UI this has solved allot of problems.
> 
> Ok, enough of that.  I was wondering about the doInsert method.  after
> an object is inserted into the databases with a primary key that is
> auto-incremented it would be convenient to set the primary key of the
> object inserted with its stored key value. Example:
> 
> // primary key field of class Foo is id.
> Foo foo = new Foo();
> foo.setBar("junk");
> //foo.getId() return null at this point.
> BaseFooPeer.doInsert(foo);
> //foo.getId() is still null at this point
> //Would be more convenient if it contained the stored id
> 
> Also, the doInsert(Foo) method return void however the
> doInsert(Criteria) return ObjectKey. is there a reason for the latter
> but not the former?

You probably want to use something like the following:

Foo foo = new Foo();
foo.setBar("junk")
foo.save()
int id = foo.getPrimaryKeyAsInt();

> 
> Thanks in advanced,
> Byron
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]

-- 
jvz.

Jason van Zyl
[EMAIL PROTECTED]

http://jakarta.apache.org/velocity
http://jakarta.apache.org/turbine
http://jakarta.apache.org/commons
http://tambora.zenplex.org

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

Reply via email to