org.garret.perst
Interface IPersistent

All Superinterfaces:
java.io.Externalizable, java.io.Serializable
All Known Subinterfaces:
BitIndex, Blob, FieldIndex, GenericIndex, Index, IPersistentSet, PatriciaTrie, SortedCollection, SpatialIndex, SpatialIndexR2, TimeSeries
All Known Implementing Classes:
Persistent

public interface IPersistent
extends java.io.Externalizable

Interface of all persistent capable objects


Method Summary
 void assignOid(Storage storage, int oid, boolean raw)
          Assign OID to the object.
 void deallocate()
          Deallocate persistent object from the database
 int getOid()
          Get object identifier (OID)
 Storage getStorage()
          Get storage in which this object is stored
 void invalidate()
          Invalidate object.
 boolean isDeleted()
          Check if object is deleted by Java GC from process memory
 boolean isModified()
          Check if object was modified within current transaction
 boolean isPersistent()
          Check if object is persistent
 boolean isRaw()
          Check if object is stub and has to be loaded from the database
 void load()
          Load object from the database (if needed)
 void loadAndModify()
          Load object from the database (if needed) and mark it as modified
 void makePersistent(Storage storage)
          Explicitely make object peristent.
 void modify()
          Mark object as modified.
 void onLoad()
          Method called by the database after loading of the object.
 void onStore()
          Method called by the database before storing of the object.
 boolean recursiveLoading()
          Specified whether object should be automatically loaded when it is referenced by other loaded peristent object.
 void store()
          Save object in the database
 
Methods inherited from interface java.io.Externalizable
readExternal, writeExternal
 

Method Detail

assignOid

public void assignOid(Storage storage,
                      int oid,
                      boolean raw)
Assign OID to the object. This method is used by storage class and you should not invoke it directly

Parameters:
storage - associated storage
oid - object identifier

deallocate

public void deallocate()
Deallocate persistent object from the database


getOid

public int getOid()
Get object identifier (OID)

Returns:
OID (0 if object is not persistent yet)

getStorage

public Storage getStorage()
Get storage in which this object is stored

Returns:
storage containing this object (null if object is not persistent yet)

invalidate

public void invalidate()
Invalidate object. Invalidated object has to be explicitly reloaded usin3g load() method. Attempt to store invalidated object will cause StoraegError exception.


isDeleted

public boolean isDeleted()
Check if object is deleted by Java GC from process memory

Returns:
true if object is deleted by GC

isModified

public boolean isModified()
Check if object was modified within current transaction

Returns:
true if object is persistent and was modified within current transaction

isPersistent

public boolean isPersistent()
Check if object is persistent

Returns:
true if object has assigned OID

isRaw

public boolean isRaw()
Check if object is stub and has to be loaded from the database

Returns:
true if object has to be loaded from the database

load

public void load()
Load object from the database (if needed)


loadAndModify

public void loadAndModify()
Load object from the database (if needed) and mark it as modified


makePersistent

public void makePersistent(Storage storage)
Explicitely make object peristent. Usually objects are made persistent implicitlely using "persistency on reachability apporach", but this method allows to do it explicitly

Parameters:
storage - storage in which object should be stored

modify

public void modify()
Mark object as modified. Object will be saved to the database during transaction commit.


onLoad

public void onLoad()
Method called by the database after loading of the object. It can be used to initialize transient fields of the object. Default implementation of this method do nothing


onStore

public void onStore()
Method called by the database before storing of the object. It can be used to save or close transient fields of the object. Default implementation of this method do nothing


recursiveLoading

public boolean recursiveLoading()
Specified whether object should be automatically loaded when it is referenced by other loaded peristent object. Default implementation of this method returns true making all cluster of referenced objects loaded together. To avoid main memory overflow you should stop recursive loading of all objects from the database to main memory by redefining this method in some classes and returing false in it. In this case object has to be loaded explicitely using Persistent.load method.

Returns:
true if object is automatically loaded

store

public void store()
Save object in the database