db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Mahler <thm...@web.de>
Subject Re: Problems with lock
Date Sun, 16 Nov 2003 10:24:53 GMT
Hi João,

The problem is that using two different objects with the same primary 
key violates the relational calculus, and OJB refuses to work that way!

If you use
a1.setName("this should be in database after commit");

the changes will be persisted to the database.


João Vieira da Luz wrote:
> Hi,
> 
> Look to this pseudo-code:
> 
> 	beginTransaction(); // odmg transaction
> 
> 	A a1 = readByPk(new Integer(1)); //using Persistence Broker Api
> 	
> 	lock Read Object a1 //using tx 
> 
> 	A a2 = new A();
> 
> 	a2.setIdInternal(new Integer(1)); // idInternal is the primary
> key 
> 
> 	lock write object a2	

As Object a1 is already locked with the same Identity the second 
registration for the same Identity is ignored, as OJB relies on the fact 
that instances have unique Identities !

cheers,
thomas

> 	
> 	a2.setName("this should be in database after commit");
> 
> 	commitTransaction(); //using tx
> 
> My question is why attribute name is not updated on database?
> 
> Thanks,
> 	João
> 
> 
> 
> 
> 
> ---------------------------------------------------------------------
> 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