Arch4J 1.1

org.arch4j.persistence.castor
Class CastorPersistenceManager

java.lang.Object
  |
  +--org.arch4j.persistence.castor.CastorPersistenceManager
All Implemented Interfaces:
PersistenceManager

public class CastorPersistenceManager
extends Object
implements PersistenceManager

Implements the PersistenceManager interface for the Castor O/R mapping tool.

Author:
alwick, dcolwell

Constructor Summary
CastorPersistenceManager(String logicalName)
          Creates a new instance of CastorPersistenceManager
 
Method Summary
 void beginTransaction()
          Begin a transaction.
 void close()
          Close the connection.
 void commit()
          Commit the transaction.
 void create(Object anObject)
          Create object or objects.
 void create(Object anObject, boolean isDeepCreate)
          Create object or objects.
 void finalize()
           
 Collection getObjects(ObjectQuery aQuery)
          Get all objects for the given query object.
 Collection getObjects(String aQueryString)
          Get all objects for the given query string.
 ObjectQuery getQuery(String anOQLQueryString)
          Gets the query object for a given query.
 boolean isPersistent(Object anObject)
          Is this object recognized by the current transaction.
 Object load(Class type, Object identity)
          Load the specified instance.
 void remove(Object anObject)
          Remove the Object.
 void rollback()
          Rollback the transaction.
 void setDefaultDeepOrShallow(boolean isDeep)
          Specifies if upcoming transactions will perform deep or shallow updates and creates.
 void update(Object anObject)
          Update existing object or objects.
 void update(Object anObject, boolean isDeepUpdate)
          Update existing object or objects.
 boolean validateTransaction()
          Validate that a transaction is started.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CastorPersistenceManager

public CastorPersistenceManager(String logicalName)
Creates a new instance of CastorPersistenceManager

Method Detail

update

public void update(Object anObject,
                   boolean isDeepUpdate)
            throws PersistenceException
Update existing object or objects.

Specified by:
update in interface PersistenceManager
Parameters:
isDeepUpdate - If true then navigate the object graph and mark the root and all children to be updated. Otherwise, update only the root object.
Throws:
PersistenceException - if this method is called on an already open transaction. Deep/shallow can only be specified in Castor before the transaction begins.

create

public void create(Object anObject,
                   boolean isDeepCreate)
            throws PersistenceException
Create object or objects.

Specified by:
create in interface PersistenceManager
Parameters:
isDeepCreate - If true then navigate the object graph and mark the root and all children to be created. Otherwise, create only the root object.
Throws:
PersistenceException - if this method is called on an already open transaction. Deep/shallow can only be specified in Castor before the transaction begins.

setDefaultDeepOrShallow

public void setDefaultDeepOrShallow(boolean isDeep)
                             throws PersistenceException
Specifies if upcoming transactions will perform deep or shallow updates and creates.

Specified by:
setDefaultDeepOrShallow in interface PersistenceManager
PersistenceException

update

public void update(Object anObject)
            throws PersistenceException
Update existing object or objects.

Specified by:
update in interface PersistenceManager
PersistenceException

create

public void create(Object anObject)
            throws PersistenceException
Create object or objects.

Specified by:
create in interface PersistenceManager
PersistenceException

isPersistent

public boolean isPersistent(Object anObject)
                     throws PersistenceException
Is this object recognized by the current transaction.

Specified by:
isPersistent in interface PersistenceManager
PersistenceException

load

public Object load(Class type,
                   Object identity)
            throws PersistenceException
Load the specified instance. This is the same as querying for the single instance specified by the primary key.

Specified by:
load in interface PersistenceManager
Parameters:
type - the class type to populate and return
identity - the primary key used to identify the instance (note that complex primary keys will be supported in a future release)
Returns:
the instance if it exists, otherwise null
PersistenceException

beginTransaction

public void beginTransaction()
                      throws PersistenceException
Begin a transaction.

Specified by:
beginTransaction in interface PersistenceManager
PersistenceException

commit

public void commit()
            throws PersistenceException
Commit the transaction.

Specified by:
commit in interface PersistenceManager
PersistenceException

rollback

public void rollback()
              throws PersistenceException
Rollback the transaction.

Specified by:
rollback in interface PersistenceManager
PersistenceException

remove

public void remove(Object anObject)
            throws PersistenceException
Remove the Object. This method can only be used from within a bounded transaction. In other words, the calling code must have a persistenceMgr.beginTransaction() call and query for the object to bind it to the transaction before calling persistenceMgr.remove().

Specified by:
remove in interface PersistenceManager
PersistenceException

getObjects

public Collection getObjects(String aQueryString)
                      throws PersistenceException
Get all objects for the given query string. Transaction validation is handled by the implementation method, getObjects(ObjectQuery)

Specified by:
getObjects in interface PersistenceManager
PersistenceException

getObjects

public Collection getObjects(ObjectQuery aQuery)
                      throws PersistenceException
Get all objects for the given query object.

Specified by:
getObjects in interface PersistenceManager
Parameters:
aQuery - The query object to use for the query.
Returns:
The objects that match the query.
PersistenceException

getQuery

public ObjectQuery getQuery(String anOQLQueryString)
                     throws PersistenceException
Gets the query object for a given query.

Specified by:
getQuery in interface PersistenceManager
PersistenceException

validateTransaction

public boolean validateTransaction()
                            throws PersistenceException
Validate that a transaction is started. Start one if it hasn't.

Specified by:
validateTransaction in interface PersistenceManager
Returns:
true if a new transaction was started.
PersistenceException

finalize

public void finalize()
              throws Throwable
Overrides:
finalize in class Object
Throwable

close

public void close()
           throws PersistenceException
Close the connection.

Specified by:
close in interface PersistenceManager
PersistenceException

Arch4J 1.1

Copyright © 2000-2004 SpiderLogic, a service of Wipfli Ullrich Bertelson LLP.