[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: nameForObject()?
On Mon, 29 Jan 2001, Andreas Monitzer wrote:
> hi
>
> I need the opposite of org.ozoneDB.ExternalDatabase.objectForName(), is there something available? I could just store the string inside the database object, but that wouldn't be very efficient.
>
> Background story:
>
> I got one database object which points to another database object.
> One object stores the proxy of the other by using the following:
>
> class FirstObjectImpl extends OzoneRemote implements FirstObject {
> private transient SecondObject obj=null;
> private String objId;
>
> public FirstObjectImpl(SecondObject in_obj) {
> obj=in_obj;
> objId=in_obj.getId(); // how?
> }
>
> public getSecondObject() {
> if(obj==null)
> obj=db.objectForName(objId); // db is static
> return obj;
> }
> }
Why do you need this extra reference via the object name? You may simply say:
public SecondObject getSecondObject() {
return obj;
}
and setting the obj member to be non-transient of course.
BTW: from inside a database object you should never acces the database via a
static variable but via the database() method which all database object classes
inherit by OzoneCompatible.
Falko
--
______________________________________________________________________
Falko Braeutigam mailto:falko@smb-tec.com
SMB GmbH http://www.smb-tec.com