You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Gene <ge...@yahoo.com> on 2004/12/03 01:31:38 UTC
How to obtain autoincrement field value once an object is created?
Hi, anyone can tell me if I can obtain the autoincrement field value when I
create an object? Because I would like to assign the same value to another
field. For example:
field "Id" is an autocrement field, and "TheSameValueField" is a normal field, I
want to default/assign the value of "Id" field to field "TheSameValueField", how
to realize that?
Any ideas are appreciated. Thanks.
Gene
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: How to obtain autoincrement field value once an object is
created?
Posted by "Robert S. Sfeir" <ro...@codepuccino.com>.
Not if you setup the primary key correctly and the foreign references.
On 12/2/04 11:00 PM, "Gene" <ge...@yahoo.com> wrote:
> But before I can store() the object, I must filled the TheSameValueField
> with values(same as Id field) as it is a not null field/column.
> Otherwise, database error will be raised.
>
> Gene
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
R
--
Robert S. Sfeir
Software Developer
Codepuccino
"Make everything as simple as possible, but not simpler." -- Einstein
http://www.codepuccino.com
blog: http://blogs.codepuccino.com/dude
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: How to obtain autoincrement field value once an object is created?
Posted by Gene <ge...@yahoo.com>.
But before I can store() the object, I must filled the TheSameValueField
with values(same as Id field) as it is a not null field/column.
Otherwise, database error will be raised.
Gene
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: How to obtain autoincrement field value once an object is
created?
Posted by "Robert S. Sfeir" <ro...@codepuccino.com>.
Most of the time the broker.store() object will return the object you passed
in with the ID (primary key value) filled in. So just do a Object.getID()
(of course substituting your object name and method name) after you've done
the store and you'll have the ID.
R
On 12/2/04 7:31 PM, "Gene" <ge...@yahoo.com> wrote:
> Hi, anyone can tell me if I can obtain the autoincrement field value when I
> create an object? Because I would like to assign the same value to another
> field. For example:
> field "Id" is an autocrement field, and "TheSameValueField" is a normal field,
> I
> want to default/assign the value of "Id" field to field "TheSameValueField",
> how
> to realize that?
>
> Any ideas are appreciated. Thanks.
>
> Gene
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
R
--
Robert S. Sfeir
Software Developer
Codepuccino
"Make everything as simple as possible, but not simpler." -- Einstein
http://www.codepuccino.com
blog: http://blogs.codepuccino.com/dude
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org