org.synchronoss.cpo
Class CpoAdapterBean

Package class diagram package CpoAdapterBean
java.lang.Object
  extended by org.synchronoss.cpo.CpoAdapterBean
All Implemented Interfaces:
java.io.Serializable, javax.ejb.EnterpriseBean, javax.ejb.SessionBean, CpoAdapter

public class CpoAdapterBean
extends java.lang.Object
implements CpoAdapter, javax.ejb.SessionBean

See Also:
Serialized Form

Field Summary
 
Fields inherited from interface org.synchronoss.cpo.CpoAdapter
CREATE, DELETE, EXECUTE, EXIST, INSERT, LIST, PERSIST, RETRIEVE, UPDATE
 
Constructor Summary
CpoAdapterBean(CpoAdapter cpo)
           
 
Method Summary
 void clearMetaClass()
          Clears the metadata for all classes for the current datasource.
 void clearMetaClass(boolean all)
          Clears the metadata for all classes.
 void clearMetaClass(java.lang.Object obj)
          Clears the metadata for the specified object.
 void clearMetaClass(java.lang.String className)
          Clears the metadata for the specified fully qualifed class name.
<T> long
deleteObject(java.lang.String name, T obj)
          Removes the Object from the datasource.
<T> long
deleteObject(T obj)
          Removes the Object from the datasource.
<T> long
deleteObjects(java.util.Collection<T> coll)
          Removes the Objects contained in the collection from the datasource.
<T> long
deleteObjects(java.lang.String name, java.util.Collection<T> coll)
          Removes the Objects contained in the collection from the datasource.
 void ejbActivate()
           
 void ejbCreate()
           
 void ejbPassivate()
           
 void ejbRemove()
           
 java.lang.Object executeAdapterMethod(java.lang.String name, java.lang.Class<?>[] parameterTypes, java.lang.Object[] args)
           
<T,C> T
executeObject(java.lang.String name, C criteria, T result)
          Executes an Object whose MetaData contains a stored procedure.
<T> T
executeObject(java.lang.String name, T object)
          Executes an Object whose MetaData contains a stored procedure.
<T> T
executeObject(T object)
          Executes an Object whose MetaData contains a stored procedure.
<T> long
existsObject(java.lang.String name, T obj)
          The CpoAdapter will check to see if this object exists in the datasource.
<T> long
existsObject(java.lang.String name, T obj, java.util.Collection<CpoWhere> wheres)
          The CpoAdapter will check to see if this object exists in the datasource.
<T> long
existsObject(T obj)
          The CpoAdapter will check to see if this object exists in the datasource.
 java.lang.Class<?> getAdapterClass()
           
 CpoTrxAdapter getCpoTrxAdapter()
          Provides a mechanism for the user to obtain a CpoTrxAdapter object.
<T> long
insertObject(java.lang.String name, T obj)
          Creates the Object and stores it in the datasource.
<T> long
insertObject(T obj)
          Creates the Object and stores it in the datasource.
<T> long
insertObjects(java.util.Collection<T> coll)
          Iterates through a collection of Objects, creates them and stores them in the datasource.
<T> long
insertObjects(java.lang.String name, java.util.Collection<T> coll)
          Iterates through a collection of Objects, creates them and stores them in the datasource.
 CpoOrderBy newOrderBy(java.lang.String attribute, boolean ascending)
          newOrderBy allows you to dynamically change the order of the objects in the resulting collection.
 CpoOrderBy newOrderBy(java.lang.String attribute, boolean ascending, java.lang.String function)
          newOrderBy allows you to dynamically change the order of the objects in the resulting collection.
 CpoWhere newWhere()
          DOCUMENT ME!
<T> CpoWhere
newWhere(int logical, java.lang.String attr, int comp, T value)
          DOCUMENT ME!
<T> CpoWhere
newWhere(int logical, java.lang.String attr, int comp, T value, boolean not)
          DOCUMENT ME!
<T> long
persistObject(java.lang.String name, T obj)
          Persists the Object into the datasource.
<T> long
persistObject(T obj)
          Persists the Object into the datasource.
<T> long
persistObjects(java.util.Collection<T> coll)
          Persists a collection of Objects into the datasource.
<T> long
persistObjects(java.lang.String name, java.util.Collection<T> coll)
          Persists a collection of Objects into the datasource.
<T,C> T
retrieveObject(java.lang.String name, C criteria, T result, java.util.Collection<CpoWhere> wheres, java.util.Collection<CpoOrderBy> orderBy)
          Retrieves the Object from the datasource.
<T,C> T
retrieveObject(java.lang.String name, C criteria, T result, java.util.Collection<CpoWhere> wheres, java.util.Collection<CpoOrderBy> orderBy, java.util.Collection<CpoNativeQuery> nativeQuery)
          Retrieves the Object from the datasource.
<T> T
retrieveObject(java.lang.String name, T obj)
          Retrieves the Object from the datasource.
<T> T
retrieveObject(T obj)
          Retrieves the Object from the datasource.
<T,C> java.util.Collection<T>
retrieveObjects(java.lang.String name, C criteria, java.util.Collection<CpoWhere> wheres, java.util.Collection<CpoOrderBy> orderBy, java.util.Collection<CpoNativeQuery> nativeQuery, T result)
          Retrieves the Object from the datasource.
<T,C> CpoResultSet<T>
retrieveObjects(java.lang.String name, C criteria, java.util.Collection<CpoWhere> wheres, java.util.Collection<CpoOrderBy> orderBy, java.util.Collection<CpoNativeQuery> nativeQuery, T result, int queueSize)
          Retrieves the Object from the datasource.
<T,C> java.util.Collection<T>
retrieveObjects(java.lang.String name, C criteria, java.util.Collection<CpoWhere> wheres, java.util.Collection<CpoOrderBy> orderBy, T result)
          Retrieves the Object from the datasource.
 void setSessionContext(javax.ejb.SessionContext A)
           
<T> long
transactObjects(java.util.Collection<CpoObject<T>> coll)
          Deprecated.  
<T> long
updateObject(java.lang.String name, T obj)
          Persists the Object into the datasource.
<T> long
updateObject(T obj)
          Persists the Object into the datasource.
<T> long
updateObjects(java.util.Collection<T> coll)
          Persists a collection of Objects into the datasource.
<T> long
updateObjects(java.lang.String name, java.util.Collection<T> coll)
          Persists a collection of Objects into the datasource.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CpoAdapterBean

public CpoAdapterBean(CpoAdapter cpo)
Method Detail

ejbCreate

public void ejbCreate()

ejbActivate

public void ejbActivate()
Specified by:
ejbActivate in interface javax.ejb.SessionBean

ejbPassivate

public void ejbPassivate()
Specified by:
ejbPassivate in interface javax.ejb.SessionBean

ejbRemove

public void ejbRemove()
Specified by:
ejbRemove in interface javax.ejb.SessionBean

setSessionContext

public void setSessionContext(javax.ejb.SessionContext A)
Specified by:
setSessionContext in interface javax.ejb.SessionBean

getAdapterClass

public java.lang.Class<?> getAdapterClass()
                                   throws CpoException
Throws:
CpoException

executeAdapterMethod

public java.lang.Object executeAdapterMethod(java.lang.String name,
                                             java.lang.Class<?>[] parameterTypes,
                                             java.lang.Object[] args)
                                      throws CpoException
Throws:
CpoException

insertObject

public <T> long insertObject(T obj)
                  throws CpoException
Creates the Object and stores it in the datasource. The assumption is that the object does not exist in the datasource. This method creates and stores the object in the datasource

Specified by:
insertObject in interface CpoAdapter
Parameters:
obj - This is an object that has been defined within the metadata of the datasource. If the class is not defined an exception will be thrown.
Returns:
The number of objects created in the datasource
Throws:
CpoException - Thrown if there are errors accessing the datasource

insertObject

public <T> long insertObject(java.lang.String name,
                             T obj)
                  throws CpoException
Creates the Object and stores it in the datasource. The assumption is that the object does not exist in the datasource. This method creates and stores the object in the datasource

Specified by:
insertObject in interface CpoAdapter
Parameters:
obj - This is an object that has been defined within the metadata of the datasource. If the class is not defined an exception will be thrown.
name - The String name of the CREATE Query group that will be used to create the object in the datasource. null signifies that the default rules will be used which is equivalent to insertObject(Object obj);
Returns:
The number of objects created in the datasource
Throws:
CpoException - Thrown if there are errors accessing the datasource

insertObjects

public <T> long insertObjects(java.util.Collection<T> coll)
                   throws CpoException
Iterates through a collection of Objects, creates them and stores them in the datasource. The assumption is that the objects contained in the collection do not exist in the datasource. This method creates and stores the objects in the datasource. The objects in the collection will be treated as one transaction, meaning that if one of the objects fail being created in the datasource then the entire collection will be rolled back

Specified by:
insertObjects in interface CpoAdapter
Parameters:
coll - This is a collection of objects that have been defined within the metadata of the datasource. If the class is not defined an exception will be thrown.
Returns:
The number of objects created in the datasource
Throws:
CpoException - Thrown if there are errors accessing the datasource

insertObjects

public <T> long insertObjects(java.lang.String name,
                              java.util.Collection<T> coll)
                   throws CpoException
Iterates through a collection of Objects, creates them and stores them in the datasource. The assumption is that the objects contained in the collection do not exist in the datasource. This method creates and stores the objects in the datasource. The objects in the collection will be treated as one transaction, meaning that if one of the objects fail being created in the datasource then the entire collection will be rolled back

Specified by:
insertObjects in interface CpoAdapter
Parameters:
name - The the context name for which group of operations will be called to process this insert.
coll - This is a collection of objects that have been defined within the metadata of the datasource. If the class is not defined an exception will be thrown.
Returns:
The number of objects created in the datasource
Throws:
CpoException - Thrown if there are errors accessing the datasource

retrieveObject

public <T> T retrieveObject(T obj)
                 throws CpoException
Retrieves the Object from the datasource. The assumption is that the object exists in the datasource. If the retrieve query defined for this objects returns more than one row, an exception will be thrown.

Specified by:
retrieveObject in interface CpoAdapter
Parameters:
obj - This is an object that has been defined within the metadata of the datasource. If the class is not defined an exception will be thrown. If the object does not exist in the datasource, an exception will be thrown. The input object is used to specify the search criteria, the output object is populated with the results of the query.
Returns:
An object of the same type as the result parameter that is filled in as specified the metadata for the retireve.
Throws:
CpoException - Thrown if there are errors accessing the datasource

retrieveObject

public <T> T retrieveObject(java.lang.String name,
                            T obj)
                 throws CpoException
Retrieves the Object from the datasource. The assumption is that the object exists in the datasource. If the retrieve query defined for this objects returns more than one row, an exception will be thrown.

Specified by:
retrieveObject in interface CpoAdapter
Parameters:
name - The the context name for which group of operations will be called to process this retrieve.
obj - This is an object that has been defined within the metadata of the datasource. If the class is not defined an exception will be thrown. If the object does not exist in the datasource, an exception will be thrown. The input object is used to specify the search criteria, the output object is populated with the results of the query.
Returns:
An object of the same type as the result parameter that is filled in as specified the metadata for the retireve.
Throws:
CpoException - Thrown if there are errors accessing the datasource

retrieveObject

public <T,C> T retrieveObject(java.lang.String name,
                              C criteria,
                              T result,
                              java.util.Collection<CpoWhere> wheres,
                              java.util.Collection<CpoOrderBy> orderBy)
                 throws CpoException
Retrieves the Object from the datasource. The assumption is that the object exists in the datasource. If the retrieve query defined for this objects returns more than one row, an exception will be thrown.

Specified by:
retrieveObject in interface CpoAdapter
Parameters:
name - The the context name for which group of operations will be called to process this retrieve.
criteria - This is an object that has been defined within the metadata of the datasource. If the class is not defined an exception will be thrown. If the object does not exist in the datasource, an exception will be thrown. This object is used to specify the parameters used to retrieve the collection of objects.
result - This is an object that has been defined within the metadata of the datasource. If the class is not defined an exception will be thrown. If the object does not exist in the datasource, an exception will be thrown. This object is used to specify the object type that will be returned in the collection.
wheres - A collection of CpoWhere objects that define the constraints that should be used when retrieving objects
orderBy - The CpoOrderBy object that defines the order in which objects should be returned
Returns:
An object of the same type as the result parameter that is filled in as specified the metadata for the retireve.
Throws:
CpoException - Thrown if there are errors accessing the datasource

retrieveObject

public <T,C> T retrieveObject(java.lang.String name,
                              C criteria,
                              T result,
                              java.util.Collection<CpoWhere> wheres,
                              java.util.Collection<CpoOrderBy> orderBy,
                              java.util.Collection<CpoNativeQuery> nativeQuery)
                 throws CpoException
Retrieves the Object from the datasource. The assumption is that the object exists in the datasource. If the retrieve query defined for this objects returns more than one row, an exception will be thrown.

Specified by:
retrieveObject in interface CpoAdapter
Parameters:
name - The the context name for which group of operations will be called to process this retrieve.
criteria - This is an object that has been defined within the metadata of the datasource. If the class is not defined an exception will be thrown. If the object does not exist in the datasource, an exception will be thrown. This object is used to specify the parameters used to retrieve the collection of objects.
result - This is an object that has been defined within the metadata of the datasource. If the class is not defined an exception will be thrown. If the object does not exist in the datasource, an exception will be thrown. This object is used to specify the object type that will be returned in the collection.
wheres - A collection of CpoWhere objects that define the constraints that should be used when retrieving objects
orderBy - The CpoOrderBy object that defines the order in which objects should be returned
nativeQuery - Native query text that will be used to augment the query text stored in the meta data. This text will be embedded at run-time
Returns:
An object of the same type as the result parameter that is filled in as specified the metadata for the retireve.
Throws:
CpoException - Thrown if there are errors accessing the datasource

retrieveObjects

public <T,C> java.util.Collection<T> retrieveObjects(java.lang.String name,
                                                     C criteria,
                                                     java.util.Collection<CpoWhere> wheres,
                                                     java.util.Collection<CpoOrderBy> orderBy,
                                                     T result)
                                        throws CpoException
Retrieves the Object from the datasource. The assumption is that the object exists in the datasource.

Specified by:
retrieveObjects in interface CpoAdapter
Parameters:
name - The the context name for which group of operations will be called to process this retrieve.
criteria - This is an object that has been defined within the metadata of the datasource. If the class is not defined an exception will be thrown. If the object does not exist in the datasource, an exception will be thrown. This object is used to specify the parameters used to retrieve the collection of objects.
result - This is an object that has been defined within the metadata of the datasource. If the class is not defined an exception will be thrown. If the object does not exist in the datasource, an exception will be thrown. This object is used to specify the object type that will be returned in the collection.
wheres - A collection of CpoWhere objects that define the constraints that should be used when retrieving objects
orderBy - The CpoOrderBy object that defines the order in which objects should be returned
Returns:
A collection of objects will be returned that meet the criteria specified by obj. The objects will be of the same type as the Object that was passed in. If no objects match the criteria, an empty collection will be returned
Throws:
CpoException - Thrown if there are errors accessing the datasource

retrieveObjects

public <T,C> java.util.Collection<T> retrieveObjects(java.lang.String name,
                                                     C criteria,
                                                     java.util.Collection<CpoWhere> wheres,
                                                     java.util.Collection<CpoOrderBy> orderBy,
                                                     java.util.Collection<CpoNativeQuery> nativeQuery,
                                                     T result)
                                        throws CpoException
Retrieves the Object from the datasource. The assumption is that the object exists in the datasource.

Specified by:
retrieveObjects in interface CpoAdapter
Parameters:
name - The the context name for which group of operations will be called to process this retrieve.
criteria - This is an object that has been defined within the metadata of the datasource. If the class is not defined an exception will be thrown. If the object does not exist in the datasource, an exception will be thrown. This object is used to specify the parameters used to retrieve the collection of objects.
result - This is an object that has been defined within the metadata of the datasource. If the class is not defined an exception will be thrown. If the object does not exist in the datasource, an exception will be thrown. This object is used to specify the object type that will be returned in the collection.
wheres - A collection of CpoWhere objects that define the constraints that should be used when retrieving objects
orderBy - The CpoOrderBy object that defines the order in which objects should be returned
nativeQuery - Native query text that will be used to augment the query text stored in the meta data. This text will be embedded at run-time
Returns:
A collection of objects will be returned that meet the criteria specified by obj. The objects will be of the same type as the Object that was passed in. If no objects match the criteria, an empty collection will be returned
Throws:
CpoException - Thrown if there are errors accessing the datasource

updateObject

public <T> long updateObject(T obj)
                  throws CpoException
Persists the Object into the datasource. The assumption is that the object exists in the datasource. This method stores the object in the datasource

Specified by:
updateObject in interface CpoAdapter
Parameters:
obj - This is an object that has been defined within the metadata of the datasource. If the class is not defined an exception will be thrown.
Returns:
The number of objects updated in the datasource
Throws:
CpoException - Thrown if there are errors accessing the datasource

updateObject

public <T> long updateObject(java.lang.String name,
                             T obj)
                  throws CpoException
Persists the Object into the datasource. The assumption is that the object exists in the datasource. This method stores the object in the datasource

Specified by:
updateObject in interface CpoAdapter
Parameters:
obj - This is an object that has been defined within the metadata of the datasource. If the class is not defined an exception will be thrown.
name - The String name of the UPDATE Query group that will be used to create the object in the datasource. null signifies that the default rules will be used.
Returns:
The number of objects updated in the datasource
Throws:
CpoException - Thrown if there are errors accessing the datasource

updateObjects

public <T> long updateObjects(java.util.Collection<T> coll)
                   throws CpoException
Persists a collection of Objects into the datasource. The assumption is that the objects contained in the collection exist in the datasource. This method stores the object in the datasource. The objects in the collection will be treated as one transaction, meaning that if one of the objects fail being updated in the datasource then the entire collection will be rolled back. If no rows are updated, no exception is thrown

Specified by:
updateObjects in interface CpoAdapter
Parameters:
coll - This is a collection of objects that have been defined within the metadata of the datasource. If the class is not defined an exception will be thrown.
Returns:
The number of objects updated in the datasource
Throws:
CpoException - Thrown if there are errors accessing the datasource

updateObjects

public <T> long updateObjects(java.lang.String name,
                              java.util.Collection<T> coll)
                   throws CpoException
Persists a collection of Objects into the datasource. The assumption is that the objects contained in the collection exist in the datasource. This method stores the object in the datasource. The objects in the collection will be treated as one transaction, meaning that if one of the objects fail being updated in the datasource then the entire collection will be rolled back. If no rows are updated, no exception is thrown

Specified by:
updateObjects in interface CpoAdapter
Parameters:
coll - This is a collection of objects that have been defined within the metadata of the datasource. If the class is not defined an exception will be thrown.
name - The String name of the UPDATE Query group that will be used to create the object in the datasource. null signifies that the default rules will be used.
Returns:
The number of objects updated in the datasource
Throws:
CpoException - Thrown if there are errors accessing the datasource

deleteObject

public <T> long deleteObject(T obj)
                  throws CpoException
Removes the Object from the datasource. The assumption is that the object exists in the datasource. This method stores the object in the datasource

Specified by:
deleteObject in interface CpoAdapter
Parameters:
obj - This is an object that has been defined within the metadata of the datasource. If the class is not defined an exception will be thrown. If the object does not exist in the datasource an exception will be thrown.
Returns:
The number of objects deleted from the datasource
Throws:
CpoException - Thrown if there are errors accessing the datasource

deleteObject

public <T> long deleteObject(java.lang.String name,
                             T obj)
                  throws CpoException
Removes the Object from the datasource. The assumption is that the object exists in the datasource. This method stores the object in the datasource

Specified by:
deleteObject in interface CpoAdapter
Parameters:
obj - This is an object that has been defined within the metadata of the datasource. If the class is not defined an exception will be thrown. If the object does not exist in the datasource an exception will be thrown.
name - The String name of the DELETE Query group that will be used to create the object in the datasource. null signifies that the default rules will be used.
Returns:
The number of objects deleted from the datasource
Throws:
CpoException - Thrown if there are errors accessing the datasource

deleteObjects

public <T> long deleteObjects(java.util.Collection<T> coll)
                   throws CpoException
Removes the Objects contained in the collection from the datasource. The assumption is that the object exists in the datasource. This method stores the objects contained in the collection in the datasource. The objects in the collection will be treated as one transaction, meaning that if one of the objects fail being deleted from the datasource then the entire collection will be rolled back.

Specified by:
deleteObjects in interface CpoAdapter
Parameters:
coll - This is a collection of objects that have been defined within the metadata of the datasource. If the class is not defined an exception will be thrown.
Returns:
The number of objects deleted from the datasource
Throws:
CpoException - Thrown if there are errors accessing the datasource

deleteObjects

public <T> long deleteObjects(java.lang.String name,
                              java.util.Collection<T> coll)
                   throws CpoException
Removes the Objects contained in the collection from the datasource. The assumption is that the object exists in the datasource. This method stores the objects contained in the collection in the datasource. The objects in the collection will be treated as one transaction, meaning that if one of the objects fail being deleted from the datasource then the entire collection will be rolled back.

Specified by:
deleteObjects in interface CpoAdapter
Parameters:
coll - This is a collection of objects that have been defined within the metadata of the datasource. If the class is not defined an exception will be thrown.
name - The String name of the DELETE Query group that will be used to create the object in the datasource. null signifies that the default rules will be used.
Returns:
The number of objects deleted from the datasource
Throws:
CpoException - Thrown if there are errors accessing the datasource

persistObject

public <T> long persistObject(T obj)
                   throws CpoException
Persists the Object into the datasource. The CpoAdapter will check to see if this object exists in the datasource. If it exists, the object is updated in the datasource If the object does not exist, then it is created in the datasource. This method stores the object in the datasource

Specified by:
persistObject in interface CpoAdapter
Parameters:
obj - This is an object that has been defined within the metadata of the datasource. If the class is not defined an exception will be thrown.
name - The name which identifies which EXISTS, INSERT, and UPDATE Query groups to execute to persist the object.
Returns:
A count of the number of objects persisted
Throws:
An - exception is thrown if existsObject() returns a value > 1
CpoException - Thrown if there are errors accessing the datasource
See Also:
existsObject(T), insertObject(T), updateObject(T)

persistObject

public <T> long persistObject(java.lang.String name,
                              T obj)
                   throws CpoException
Persists the Object into the datasource. The CpoAdapter will check to see if this object exists in the datasource. If it exists, the object is updated in the datasource If the object does not exist, then it is created in the datasource. This method stores the object in the datasource

Specified by:
persistObject in interface CpoAdapter
Parameters:
name - The name which identifies which EXISTS, INSERT, and UPDATE Query groups to execute to persist the object.
obj - This is an object that has been defined within the metadata of the datasource. If the class is not defined an exception will be thrown.
Returns:
A count of the number of objects persisted
Throws:
An - exception is thrown if existsObject() returns a value > 1
CpoException - Thrown if there are errors accessing the datasource
See Also:
existsObject(T), insertObject(T), updateObject(T)

persistObjects

public <T> long persistObjects(java.util.Collection<T> coll)
                    throws CpoException
Persists a collection of Objects into the datasource. The CpoAdapter will check to see if this object exists in the datasource. If it exists, the object is updated in the datasource If the object does not exist, then it is created in the datasource. This method stores the object in the datasource. The objects in the collection will be treated as one transaction, meaning that if one of the objects fail being inserted or updated in the datasource then the entire collection will be rolled back.

Specified by:
persistObjects in interface CpoAdapter
Parameters:
coll - This is a collection of objects that have been defined within the metadata of the datasource. If the class is not defined an exception will be thrown.
name - The name which identifies which EXISTS, INSERT, and UPDATE Query groups to execute to persist the object.
Returns:
A count of the number of objects persisted
Throws:
An - exception is thrown if existsObject() returns a value > 1
CpoException
java.rmi.RemoteException
See Also:
existsObject(T), insertObject(T), updateObject(T)

persistObjects

public <T> long persistObjects(java.lang.String name,
                               java.util.Collection<T> coll)
                    throws CpoException
Persists a collection of Objects into the datasource. The CpoAdapter will check to see if this object exists in the datasource. If it exists, the object is updated in the datasource If the object does not exist, then it is created in the datasource. This method stores the object in the datasource. The objects in the collection will be treated as one transaction, meaning that if one of the objects fail being inserted or updated in the datasource then the entire collection will be rolled back.

Specified by:
persistObjects in interface CpoAdapter
Parameters:
name - The name which identifies which EXISTS, INSERT, and UPDATE Query groups to execute to persist the object.
coll - This is a collection of objects that have been defined within the metadata of the datasource. If the class is not defined an exception will be thrown.
Returns:
A count of the number of objects persisted
Throws:
An - exception is thrown if existsObject() returns a value > 1
CpoException
java.rmi.RemoteException
See Also:
existsObject(T), insertObject(T), updateObject(T)

existsObject

public <T> long existsObject(T obj)
                  throws CpoException
The CpoAdapter will check to see if this object exists in the datasource.

Specified by:
existsObject in interface CpoAdapter
Parameters:
obj - This is an object that has been defined within the metadata of the datasource. If the class is not defined an exception will be thrown.
name - The name which identifies which EXISTS, INSERT, and UPDATE Query groups to execute to persist the object.
Returns:
The int value of the first column returned in the record set
Throws:
An - exception will be thrown if the Query Group has a query count != 1
An - exception will be thrown if the resultset has a record count != 1
An - exception will be thrown if there is a column count != 1
An - exception will be thrown if the column returned cannot be converted to an int
CpoException - Thrown if there are errors accessing the datasource

existsObject

public <T> long existsObject(java.lang.String name,
                             T obj)
                  throws CpoException
The CpoAdapter will check to see if this object exists in the datasource.

Specified by:
existsObject in interface CpoAdapter
Parameters:
name - The name which identifies which EXISTS, INSERT, and UPDATE Query groups to execute to persist the object.
obj - This is an object that has been defined within the metadata of the datasource. If the class is not defined an exception will be thrown.
Returns:
The int value of the first column returned in the record set
Throws:
An - exception will be thrown if the Query Group has a query count != 1
An - exception will be thrown if the resultset has a record count != 1
An - exception will be thrown if there is a column count != 1
An - exception will be thrown if the column returned cannot be converted to an int
CpoException - Thrown if there are errors accessing the datasource

existsObject

public <T> long existsObject(java.lang.String name,
                             T obj,
                             java.util.Collection<CpoWhere> wheres)
                  throws CpoException
The CpoAdapter will check to see if this object exists in the datasource.
Example:
 
 class SomeObject so = new SomeObject();
 long count = 0;
 class CpoAdapter cpo = null;
 
  
  try {
    cpo = new JdbcCpoAdapter(new JdbcDataSourceInfo(driver, url, user, password,1,1,false));
  } catch (CpoException ce) {
    // Handle the error
    cpo = null;
  }
  
  if (cpo!=null) {
    so.setId(1);
    so.setName("SomeName");
    try{
      CpoWhere where = cpo.newCpoWhere(CpoWhere.LOGIC_NONE, id, CpoWhere.COMP_EQ);
      count = cpo.existsObject("SomeExistCheck",so, where);
      if (count>0) {
        // object exists
      } else {
        // object does not exist
      }
    } catch (CpoException ce) {
      // Handle the error
    }
  }

Specified by:
existsObject in interface CpoAdapter
Parameters:
name - The String name of the EXISTS Query group that will be used to create the object in the datasource. null signifies that the default rules will be used.
obj - This is an object that has been defined within the metadata of the datasource. If the class is not defined an exception will be thrown. This object will be searched for inside the datasource.
wheres - A Collection of CpoWhere objects that pass in run-time constraints to the query that performs the the exist
Returns:
The number of objects that exist in the datasource that match the specified object
Throws:
CpoException - Thrown if there are errors accessing the datasource

executeObject

public <T> T executeObject(T object)
                throws CpoException
Executes an Object whose MetaData contains a stored procedure. An assumption is that the object exists in the datasource.

Specified by:
executeObject in interface CpoAdapter
Parameters:
criteria - This is an object that has been defined within the metadata of the datasource. If the class is not defined an exception will be thrown. If the object does not exist in the datasource, an exception will be thrown. This object is used to populate the IN parameters used to retrieve the collection of objects.
result - This is an object that has been defined within the metadata of the datasource. If the class is not defined an exception will be thrown. If the object does not exist in the datasource, an exception will be thrown. This object defines the object type that will be returned in the collection and contain the result set data or the OUT Parameters.
name - The filter name which tells the datasource which objects should be returned. The name also signifies what data in the object will be populated.
Returns:
A result object populate with the OUT parameters
Throws:
CpoException - Thrown if there are errors accessing the datasource

executeObject

public <T> T executeObject(java.lang.String name,
                           T object)
                throws CpoException
Executes an Object whose MetaData contains a stored procedure. An assumption is that the object exists in the datasource.

Specified by:
executeObject in interface CpoAdapter
Parameters:
name - The filter name which tells the datasource which objects should be returned. The name also signifies what data in the object will be populated.
object - This is an object that has been defined within the metadata of the datasource. If the class is not defined an exception will be thrown. If the object does not exist in the datasource, an exception will be thrown. This object is used to populate the IN parameters used to retrieve the collection of objects. This object defines the object type that will be returned in the collection and contain the result set data or the OUT Parameters.
Returns:
A result object populate with the OUT parameters
Throws:
CpoException - DOCUMENT ME!

executeObject

public <T,C> T executeObject(java.lang.String name,
                             C criteria,
                             T result)
                throws CpoException
Executes an Object whose MetaData contains a stored procedure. An assumption is that the object exists in the datasource.

Specified by:
executeObject in interface CpoAdapter
Parameters:
name - The filter name which tells the datasource which objects should be returned. The name also signifies what data in the object will be populated.
criteria - This is an object that has been defined within the metadata of the datasource. If the class is not defined an exception will be thrown. If the object does not exist in the datasource, an exception will be thrown. This object is used to populate the IN parameters used to retrieve the collection of objects.
result - This is an object that has been defined within the metadata of the datasource. If the class is not defined an exception will be thrown. If the object does not exist in the datasource, an exception will be thrown. This object defines the object type that will be returned in the collection and contain the result set data or the OUT Parameters.
Returns:
A result object populate with the OUT parameters
Throws:
CpoException - Thrown if there are errors accessing the datasource

retrieveObjects

public <T,C> CpoResultSet<T> retrieveObjects(java.lang.String name,
                                             C criteria,
                                             java.util.Collection<CpoWhere> wheres,
                                             java.util.Collection<CpoOrderBy> orderBy,
                                             java.util.Collection<CpoNativeQuery> nativeQuery,
                                             T result,
                                             int queueSize)
                                throws CpoException
Description copied from interface: CpoAdapter
Retrieves the Object from the datasource. The assumption is that the object exists in the datasource.

Specified by:
retrieveObjects in interface CpoAdapter
Parameters:
name - The filter name which tells the datasource which objects should be returned. The name also signifies what data in the object will be populated.
criteria - This is an object that has been defined within the metadata of the datasource. If the class is not defined an exception will be thrown. If the object does not exist in the datasource, an exception will be thrown. This object is used to specify the parameters used to retrieve the collection of objects.
wheres - A collection of CpoWhere objects that define the constraints that should be used when retrieving objects
orderBy - The CpoOrderBy object that defines the order in which objects should be returned
nativeQuery - Native query text that will be used to augment the query text stored in the meta data. This text will be embedded at run-time
result - This is an object that has been defined within the metadata of the datasource. If the class is not defined an exception will be thrown. If the object does not exist in the datasource, an exception will be thrown. This object is used to specify the object type that will be returned in the collection.
Returns:
A CpoResultSet that can be iterated through
Throws:
CpoException - Thrown if there are errors accessing the datasource

newOrderBy

public CpoOrderBy newOrderBy(java.lang.String attribute,
                             boolean ascending)
                      throws CpoException
Description copied from interface: CpoAdapter
newOrderBy allows you to dynamically change the order of the objects in the resulting collection. This allows you to apply user input in determining the order of the collection

Specified by:
newOrderBy in interface CpoAdapter
Parameters:
attribute - The name of the attribute from the pojo that will be sorted.
ascending - If true, sort ascending. If false sort descending.
Returns:
A CpoOrderBy object to be passed into retrieveObjects.
Throws:
CpoException - Thrown if there are errors accessing the datasource

newOrderBy

public CpoOrderBy newOrderBy(java.lang.String attribute,
                             boolean ascending,
                             java.lang.String function)
                      throws CpoException
Description copied from interface: CpoAdapter
newOrderBy allows you to dynamically change the order of the objects in the resulting collection. This allows you to apply user input in determining the order of the collection

Specified by:
newOrderBy in interface CpoAdapter
Parameters:
attribute - The name of the attribute from the pojo that will be sorted.
ascending - If true, sort ascending. If false sort descending.
function - A string which represents a datasource function that will be called on the attribute. must be contained in the function string. The attribute name will be replaced at run-time with its datasource counterpart
Returns:
A CpoOrderBy object to be passed into retrieveObjects.
Throws:
CpoException - Thrown if there are errors accessing the datasource

newWhere

public CpoWhere newWhere()
                  throws CpoException
Description copied from interface: CpoAdapter
DOCUMENT ME!

Specified by:
newWhere in interface CpoAdapter
Returns:
DOCUMENT ME!
Throws:
CpoException - Thrown if there are errors accessing the datasource

newWhere

public <T> CpoWhere newWhere(int logical,
                             java.lang.String attr,
                             int comp,
                             T value)
                  throws CpoException
Description copied from interface: CpoAdapter
DOCUMENT ME!

Specified by:
newWhere in interface CpoAdapter
Parameters:
logical - DOCUMENT ME!
attr - DOCUMENT ME!
comp - DOCUMENT ME!
value - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
CpoException - Thrown if there are errors accessing the datasource

newWhere

public <T> CpoWhere newWhere(int logical,
                             java.lang.String attr,
                             int comp,
                             T value,
                             boolean not)
                  throws CpoException
Description copied from interface: CpoAdapter
DOCUMENT ME!

Specified by:
newWhere in interface CpoAdapter
Parameters:
logical - DOCUMENT ME!
attr - DOCUMENT ME!
comp - DOCUMENT ME!
value - DOCUMENT ME!
not - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
CpoException - Thrown if there are errors accessing the datasource

clearMetaClass

public void clearMetaClass(java.lang.Object obj)
                    throws CpoException
Description copied from interface: CpoAdapter
Clears the metadata for the specified object. The metadata will be reloaded the next time that CPO is called to access this object

Specified by:
clearMetaClass in interface CpoAdapter
Parameters:
obj - The object whose metadata must be cleared
Throws:
CpoException - Thrown if there are errors accessing the datasource

clearMetaClass

public void clearMetaClass(java.lang.String className)
                    throws CpoException
Description copied from interface: CpoAdapter
Clears the metadata for the specified fully qualifed class name. The metadata will be reloaded the next time CPO is called to access this class.

Specified by:
clearMetaClass in interface CpoAdapter
Parameters:
className - The fully qualified class name for the class that needs its metadata cleared.
Throws:
CpoException - Thrown if there are errors accessing the datasource

clearMetaClass

public void clearMetaClass()
                    throws CpoException
Description copied from interface: CpoAdapter
Clears the metadata for all classes for the current datasource. The metadata will be lazy-loaded from the metadata repository as classes are accessed.

Specified by:
clearMetaClass in interface CpoAdapter
Throws:
CpoException - Thrown if there are errors accessing the datasource

clearMetaClass

public void clearMetaClass(boolean all)
                    throws CpoException
Description copied from interface: CpoAdapter
Clears the metadata for all classes. The metadata will be lazy-loaded from the metadata repository as classes are accessed.

Specified by:
clearMetaClass in interface CpoAdapter
Parameters:
all - true - clear all classes for all datasources. false - clear all classes for the current datasource.
Throws:
CpoException - Thrown if there are errors accessing the datasource

transactObjects

@Deprecated
public <T> long transactObjects(java.util.Collection<CpoObject<T>> coll)
                     throws CpoException
Deprecated. 

Description copied from interface: CpoAdapter
Allows you to perform a series of object interactions with the database. This method pre-dates CpoTrxAdapter and can be used without a programmer needing to remember to call commit() or rollback().
Example:
 
 class SomeObject so = null;
 class CpoAdapter cpo = null;
 
  try {
    cpo = new JdbcCpoAdapter(new JdbcDataSourceInfo(driver, url, user, password,1,1,false));
  } catch (CpoException ce) {
    // Handle the error
    cpo = null;
  }
  
  if (cpo!=null) {
    ArrayList al = new ArrayList();
    so = new SomeObject();
    so.setId(1);
    so.setName("SomeName");
    CpoObject cobj = new CpoObject(CpoAdapter.CREATE,"MyCreate",so);
    al.add(cobj);
    so = new SomeObject();
    so.setId(3);
    so.setName("New Name");
    CpoObject cobj = new CpoObject(CpoAdapter.PERSIST,"MyPersist",so);
    al.add(cobj);
    
    try{
      cpo.transactObjects(al);
    } catch (CpoException ce) {
      // Handle the error
    }
  }

Specified by:
transactObjects in interface CpoAdapter
Parameters:
coll - This is a collection of CpoObject objects that have been defined within the metadata of the datasource. If the class is not defined an exception will be thrown.
Returns:
The number of objects updated in the datasource
Throws:
CpoException - Thrown if there are errors accessing the datasource

getCpoTrxAdapter

public CpoTrxAdapter getCpoTrxAdapter()
                               throws CpoException
Description copied from interface: CpoAdapter
Provides a mechanism for the user to obtain a CpoTrxAdapter object. This object allows the to control when commits and rollbacks occur on CPO.
Example:
 
 class SomeObject so = null;
 class CpoAdapter cpo = null;
 class CpoTrxAdapter cpoTrx = null;
 
  try {
    cpo = new JdbcCpoAdapter(new JdbcDataSourceInfo(driver, url, user, password,1,1,false));
    cpoTrx = cpo.getCpoTrxAdapter();
  } catch (CpoException ce) {
    // Handle the error
    cpo = null;
  }
  
  if (cpo!=null) {
    try{
      for (int i=0; i<3; i++){
        so = new SomeObject();
        so.setId(1);
        so.setName("SomeName");
        cpo.updateObject("myUpdate",so);
      }
      cpoTrx.commit();
    } catch (CpoException ce) {
       // Handle the error
       cpoTrx.rollback();
    }
  }

Specified by:
getCpoTrxAdapter in interface CpoAdapter
Returns:
A CpoTrxAdapter to manage the transactionality of CPO
Throws:
CpoException - Thrown if there are errors accessing the datasource
See Also:
CpoTrxAdapter


Copyright © 2009. All Rights Reserved.