You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Sebastian <no...@gmx.net> on 2003/12/29 19:48:54 UTC

Reloading/Refreshing attributes of an persistent object

Since,
all discussions on reloading/refreshing an persistent object somehow 
ended up on different topics. Therefore I'm trying to formulate it as 
simple as possible:
What are the exact steps to refresh the attributes of a single 
persistent object without generating a new instance?
-> What settings have to be made in the class descriptor.
-> What methods of the persistence broker needs to be called.
-> Is it possible at all?
-> If it is not possible right now, will there be an option in the 
future and what could be a workaround for the moment.

Thanks in advance,
Sebastian


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: Reloading/Refreshing attributes of an persistent object

Posted by Sebastian <no...@gmx.net>.
Sebastian wrote:

> The following seems to work, but I have no clue if it's the best way to 
> reload an object:
> 
> public void reload(Object obj)
> {
>   ClassDescriptor cld = pb.getClassDescriptor(obj.getClass());
>   cld.setAlwaysRefresh(true);
>   pb.getObjectByQuery(new QueryByIdentity(obj));
> }
> 
> Any comments?

"pb.retrieveAllReferences(obj);" needs to be added ... that's what I'm 
using now:

public void reload(Object ojb)
{
   ClassDescriptor cld = pb.getClassDescriptor(rechnung.getClass());
   synchronized (cld)
   {
     boolean refresh = cld.isAlwaysRefresh();
     cld.setAlwaysRefresh(true);
     pb.getObjectByQuery(new QueryByIdentity(obj));
     pb.retrieveAllReferences(obj);
     cld.setAlwaysRefresh(refresh);
   }
}


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: Reloading/Refreshing attributes of an persistent object

Posted by Sebastian <no...@gmx.net>.
Sebastian wrote:
> Since,
> all discussions on reloading/refreshing an persistent object somehow 
> ended up on different topics. Therefore I'm trying to formulate it as 
> simple as possible:
> What are the exact steps to refresh the attributes of a single 
> persistent object without generating a new instance?
> -> What settings have to be made in the class descriptor.
> -> What methods of the persistence broker needs to be called.
> -> Is it possible at all?
> -> If it is not possible right now, will there be an option in the 
> future and what could be a workaround for the moment.
> 
> Thanks in advance,
> Sebastian

The following seems to work, but I have no clue if it's the best way to 
reload an object:

public void reload(Object obj)
{
   ClassDescriptor cld = pb.getClassDescriptor(obj.getClass());
   cld.setAlwaysRefresh(true);
   pb.getObjectByQuery(new QueryByIdentity(obj));
}

Any comments?


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org