Hi,
    I am using ojb1.0_rc4, ODMG api with OJB queries and mysql4. The problem is that 
when I persist an object and run a identity query looking for the persisted objet the 
query returns null. This only happens when I persist the object and execute the query 
in the same transaction. Is this behaviour correct or is this a bug?
    I added some example code in the end of this email for better understanding.
    Thanks for your help.

Sincerely,
    Jair Jr

Example code:

void doSomething(){
   Transaction t=implementation.newTransaction();
   t.begin();
   Question q=new Question();
   t.lock(q,t.WRITE);
   q.setStatement("a statement");
   q.setNumber(10);
   q.setSubject(Subject.PHYSICS);
   q.setCorrectAlternative(Alternative.A);
   
   Question example=new Question();
   example.setId(q.getId());
   QueryByIdentity query=new QueryByIdentity(example);
   Question loaded=(Question) ((HasBroker)t).getBroker().getObjectByQuery(query);
   //loaded==null !!! why? Shouldn't it be: loaded==q?
   t.commit();
   
   t=implementation.newTransaction();
   t.begin();
   query=new QueryByIdentity(example);
   loaded=(Question) ((HasBroker)t).getBroker().getObjectByQuery(query);
   //loaded!=null now! loaded==q!
   t.commit();
}

Reply via email to