org.benow.repository.util
Class PersistentObjectImpl

java.lang.Object
  extended by org.benow.security.SecureObject
      extended by org.benow.repository.util.PersistentObjectImpl
All Implemented Interfaces:
java.lang.Comparable, PersistentObject
Direct Known Subclasses:
ClassInfo, JSQLObject, PermissionedClassImpl, PersistentNotifier, PersistentWrapper, UseableUser

public abstract class PersistentObjectImpl
extends org.benow.security.SecureObject
implements PersistentObject, java.lang.Comparable

FIXME expose remove(tx) method (delete(tx)?) FEATURE use a proxy wrapper in conjuction with the mapping and introspection for auto population of fields during navigation. user.getRole().getPermissions().getRoles().iterator().next().getUsers();

Author:
andy

Field Summary
 ObjectRepositoryConnection conn
           
 boolean recycled
           
 
Fields inherited from class org.benow.security.SecureObject
admin
 
Fields inherited from interface org.benow.repository.util.PersistentObject
FIELD_NAME_KEY
 
Constructor Summary
protected PersistentObjectImpl()
           
 
Method Summary
 int compareTo(java.lang.Object obj)
           
protected  boolean doIsTransient()
          Overloading isTransient() can cause problems with castor, if so, overload this method instead.
 boolean equals(java.lang.Object someObject)
          Test for equality, compares primary key.
 java.lang.Object getKey()
          Get the id for this persistent object
 boolean isTransient()
          Returns true if this object is transient
 void recycle()
          FIXME best off proxied
 boolean remove()
          remove without need for transaction
 boolean remove(Transaction tx)
          Deletes this object from persistent storage.
 void repositoryAfterLoad(Transaction tx)
          Called after the object is loaded from the repository.
 void repositoryAfterPersist(Transaction tx)
          Called after this object is persisted (stored) in the repository;
 void repositoryAfterTransient()
          Called after this object is removed from the repository.
 void repositoryBeforePersist()
          Called before this object is persisted (stored) in the repository
 void repositoryBeforeTransient()
          Called before this object is removed from the repository.
 void setKey(java.lang.Object key)
          Get the id for this persistent object
 java.lang.String toString()
           
 void update()
          update without need for transaction
 void update(Transaction tx)
          Update this object in persistent storage.
 
Methods inherited from class org.benow.security.SecureObject
assertOnePermission, assertPermission, assertPermission, declarePermission, declareViewPermission, declareViewPermission
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

conn

public transient ObjectRepositoryConnection conn

recycled

public transient boolean recycled
Constructor Detail

PersistentObjectImpl

protected PersistentObjectImpl()
Method Detail

getKey

public java.lang.Object getKey()
Description copied from interface: PersistentObject
Get the id for this persistent object

Specified by:
getKey in interface PersistentObject
Returns:
key

equals

public boolean equals(java.lang.Object someObject)
Test for equality, compares primary key. NOTE: Objects with compound key must override this method.

Overrides:
equals in class java.lang.Object

setKey

public void setKey(java.lang.Object key)
Description copied from interface: PersistentObject
Get the id for this persistent object

Specified by:
setKey in interface PersistentObject

update

public void update(Transaction tx)
            throws ObjectRepositoryException
Update this object in persistent storage.

Optionally implemented in descendant classes.

Specified by:
update in interface PersistentObject
Parameters:
tx -
Throws:
ObjectRepositoryException

update

public void update()
            throws ObjectRepositoryError
Description copied from interface: PersistentObject
update without need for transaction

Specified by:
update in interface PersistentObject
Throws:
ObjectRepositoryError - if something goes wrong

remove

public boolean remove(Transaction tx)
               throws ObjectRepositoryException
Deletes this object from persistent storage.

Specified by:
remove in interface PersistentObject
Parameters:
tx -
Throws:
ObjectRepositoryException

remove

public boolean remove()
               throws ObjectRepositoryError
Description copied from interface: PersistentObject
remove without need for transaction

Specified by:
remove in interface PersistentObject
Throws:
ObjectRepositoryError - if something goes wrong

isTransient

public boolean isTransient()
Description copied from interface: PersistentObject
Returns true if this object is transient

Specified by:
isTransient in interface PersistentObject
Returns:
true if not persisted

doIsTransient

protected boolean doIsTransient()
Overloading isTransient() can cause problems with castor, if so, overload this method instead.

Returns:
true if transient

repositoryAfterLoad

public void repositoryAfterLoad(Transaction tx)
                         throws ObjectRepositoryException
Called after the object is loaded from the repository.

Parameters:
tx -
Throws:
ObjectRepositoryException

repositoryBeforePersist

public void repositoryBeforePersist()
Called before this object is persisted (stored) in the repository


repositoryAfterPersist

public void repositoryAfterPersist(Transaction tx)
                            throws ObjectRepositoryException
Called after this object is persisted (stored) in the repository;

Parameters:
tx -
Throws:
ObjectRepositoryException

repositoryBeforeTransient

public void repositoryBeforeTransient()
Called before this object is removed from the repository.


repositoryAfterTransient

public void repositoryAfterTransient()
Called after this object is removed from the repository.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

compareTo

public int compareTo(java.lang.Object obj)
Specified by:
compareTo in interface java.lang.Comparable

recycle

public void recycle()
FIXME best off proxied