Hi Carlos,

it's not a "real bug" more a combination of bad design (Identity obtain new id's if needed) and wrong usage.

In your example you are using QueryByIdentity and OJB expect that the object does exists. Internal OJB build an Identity instance using the specified Client object and use PB#getObjectByIdentity(oid) to lookup the object.
If the id fields are null, OJB still try to build an Identity for the given Client object. Identity detect that the object was "new" (no PK values) and obtain a new id from the sequence manager to build a valid Identity object.


regards,
Armin

Carlos Ch�vez wrote:
 Hello to all.

 I found a strange behavior in OJB.

 Suppose that I have the table client, the value of the field cli_id is
 taken from a sequence, the table is in PostgreSQL, cli_id is the
 primarykey and is a integer.

 if I want to recover a client using QueryByIdentity and getObjectByQuery,
 I write the following code:

      Client c = new Client();
      c.setCli_id(id);
      Query query = new QueryByIdentity(c);
      Client N = (Client) pb.getObjectByQuery(query);

 If the var "id" has a "null" value, to execute this code make the
 value of the sequence is increased.

 Of course that would not be correct to send "id" null, but I believe that
 the sequence would not have affected by this.

 I believe that it is an indirect effect that would not have to happen.

 I am using db-ojb 1.0.1.

 I'm not sure if this behavior is happening in the other version.

 somebody could verify it?

 is a Bug o a Feature ? :)

 Cheers.


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



Reply via email to