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 "Mandip S. Sangha" <ma...@sundayta.com> on 2003/04/14 19:52:18 UTC
Re: PRIMARY KEY PROBLEM
Hi All
I have a class called User that represents a users table in my database
and so on. My problem is that if one of my user rows has its primary
key set to zero, then upon retrieving this row, the framework doesn't
set the primary key to zero in my User object but instead sets the value
to the next generated key as if it were saving a new row to the
database. Does the framework not allow an integer priamry key column to
have value zero? Is this something to do with "OJB detects that the
attribute is not properly set and assigns a unique id." as stated in
Tutorial 1?
Any comments or suggestions would be greatly appreciated.
Regards
Mandip
Re: PRIMARY KEY PROBLEM
Posted by Thomas Mahler <th...@web.de>.
Hi Mandip,
I like tose easy to answer questions. :-)
Mandip S. Sangha wrote:
> Hi All
>
> I have a class called User that represents a users table in my database
> and so on. My problem is that if one of my user rows has its primary
> key set to zero, then upon retrieving this row, the framework doesn't
> set the primary key to zero in my User object but instead sets the value
> to the next generated key as if it were saving a new row to the
> database. Does the framework not allow an integer priamry key column to
> have value zero?
Yes. (at least when you use autoicrement="true" for the PK attributes.
> Is this something to do with "OJB detects that the
> attribute is not properly set and assigns a unique id." as stated in
> Tutorial 1?
exactly! a "0" is interpreted as "undefined". The intuitive reason is
that an undefined int value also equals 0.
cheers,
Thomas
> Any comments or suggestions would be greatly appreciated.
>
> Regards
> Mandip
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>