Hi Martin,
Thank you for your fast reply.
Removing an object from cache using broker.removeFromCache(o) and making
a new load of the object creates a new JVM object that points to the same
database object, right? If this is true, my problem remains because other
objects would still reference the old JVM object. Is there a way to reload
the object data without having to create a new JVM object?
Let me explain with some code what I want to do:
transaction.begin();
Customer c=new Customer();
c.setName("customer");
transaction.lock(c,transaction.WRITE); //persist the new customer
transaction.commit();
//after some time someone changes Customer's name to "new customer"
directly in the database
transaction.begin();
Customer c=loadCustomer(); // loads the customer persisted before
from cache
Order o=new Order();
o.setCustomer(c);
cache.reloadObject(c); //reload object data from database
boolean referenceOk=(c==o.getCustomer()); // I wanted referenceOk to
be true
boolean dataReloaded="new customer".equals(c.getName()); //I wanted
dataReloaded to be true
transaction.commit();
Thank you very much for your help.
Sincerely,
Jair Jr
----- Original Message -----
From: "Martin Kal�n" <[EMAIL PROTECTED]>
To: "OJB Users List" <[EMAIL PROTECTED]>
Sent: Thursday, December 04, 2003 2:08 PM
Subject: Re: hot to reload cached object?
> Jair da Silva Ferreira J�nior wrote:
>
> > Does anyone know how to "refresh" or "reload" an OJB cached object
from the database?
>
> If you are using the PersistenceBroker API, the method to use is:
> broker.removeFromCache(<object>);
>
> See
>
http://db.apache.org/ojb/api/org/apache/ojb/broker/PersistenceBroker.html#re
moveFromCache(java.lang.Object)
>
> (And then a new load, of course.)
>
> --
> Martin Kal�n
> Curalia AB Web: http://www.curalia.se
> Orrspelsv�gen 2B Mail: [EMAIL PROTECTED]
> SE-182 79 Stocksund Tel: +46-8-410 064 40
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]