db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Armin Waibel <arm...@apache.org>
Subject Re: SECUENCE of PostgreSQL increment value if use QueryByIdentity and getObjectByQuery
Date Thu, 13 Jan 2005 00:02:58 GMT
Antonio, you've got me there ;-)
I posted my reply a few seconds after yours.

As I said it's not a real bug in my opinion, because if you create an 
object instance without PK values a QueryByIdentity doesn't make sense. 
The bad design was that OJB assume that the object was "new" and obtain 
a new id (set the new id in the Client object) and create an valid id.

Maybe we should improve method PBImpl#getObjectByQuery to check for 
'null' PK fields and return 'null' or an exception in this case (using 
of QueryByIdentity)?

regards,
Armin


Antonio Gallardo wrote:
> Hi:
> 
> We are trying to fix this problem:
> 
> Using QueryByIdentity is the key is set to null, then the sequence manager
> is activated. Here is the snapshot of the code:
> 
>     Client c = new Client();
>     c.setCli_id(null);         /* <--- Set the key to null */
>     Query query = new QueryByIdentity(c);
>     Client N = (Client) pb.getObjectByQuery(query);
> 
> Here is the repo.xml of the Client c:
> 
> <class-descriptor class="my.package.Cliente" table="CLIENTE">
>   <field-descriptor name="cli_id"
>                     primarykey="true"
>                     nullable="false"
>                     default-fetch="true"
>                     autoincrement="true"
>                     sequence-name="cliente_cli_id_seq"
>                     column="CLI_ID"
>                     jdbc-type="INTEGER"/>
>   <field-descriptor name="cli_nombre"
>                     nullable="false"
>                     default-fetch="true"
>                     column="CLI_NOMBRE"
>                     jdbc-type="VARCHAR"/>
> </class-descriptor>
> 
> Why this code retrieve a nextVal from the given sequence manager. Is this
> a bug?
> 
> Please confirm id this is a bug and we will try to fix it. ;-)
> 
> BTW, we are using OBJ_1_0_RELEASE from the CVS (few minuts ago).
> 
> Best Regards,
> 
> Antonio Gallardo.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-dev-help@db.apache.org
> 
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Mime
View raw message