db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "João Vieira da Luz" <Joao....@ist.utl.pt>
Subject RE: Problems with lock
Date Sun, 16 Nov 2003 10:51:37 GMT
Thanks a lot. Now it's much clearer to me the lock scene.

By the way, how can I know if an object is already locked?

I'm working with a framework that has the notion of service filters that
are mainly used for authorization issues.
In some situations filters need to access Domain Objects that will be
changed by the service.

We solved this problem invoking service and associated filters in
separated transaction. But this is a workaround, the objective is to run
service and associated filters in the transaction.
In my example a1 will be in the filter and a2 in the service. 

Thanks one more time,
	João 




-----Original Message-----
From: thma32@web.de [mailto:thma32@web.de] 
Sent: domingo, 16 de Novembro de 2003 10:25
To: OJB Developers List
Subject: Re: Problems with lock

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


---------------------------------------------------------------------
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