Package org.synchronoss.cpo.jdbc
Class JdbcCpoAdapter
- All Implemented Interfaces:
Serializable,CpoAdapter
- Direct Known Subclasses:
JdbcCpoTrxAdapter
JdbcCpoAdapter is the JDBC implementation of
CpoAdapter, a set
of routines that are responsible for managing value beans from a jdbc datasource.- Author:
- david berry
- See Also:
-
Method Summary
Modifier and TypeMethodDescription<T> longexistsBean(CpoQuery query, T bean) The CpoAdapter will check to see if this object exists in the datasource.getCpoAttributes(String expression) Gets theCpoAttributedefinitions matching a comma-separated expression of attribute names, as declared in the meta data for this bean's class.Get the CpoMetaDescriptorstatic JdbcCpoAdaptergetInstance(JdbcCpoMetaDescriptor metaDescriptor, DataSourceInfo<DataSource> jdsiTrx) Finds or Creates a JdbcCpoAdapter.static JdbcCpoAdaptergetInstance(JdbcCpoMetaDescriptor metaDescriptor, DataSourceInfo<DataSource> jdsiWrite, DataSourceInfo<DataSource> jdsiRead) Creates a JdbcCpoAdapter.newWhere()Creates an empty CpoWhere.<T> CpoWherenewWhere(Logical logical, String attr, Comparison comp, T value) Creates a CpoWhere comparing the attribute to the value.<T> CpoWherenewWhere(Logical logical, String attr, Comparison comp, T value, boolean not) Creates a CpoWhere comparing the attribute to the value, optionally negated.Methods inherited from class org.synchronoss.cpo.core.CpoBaseAdapter
deleteBean, deleteBeans, executeBean, getBatchSize, getDataSourceName, getFetchSize, insertBean, insertBeans, newOrderBy, newOrderBy, newOrderBy, newOrderBy, retrieveBean, retrieveBean, retrieveBeans, setBatchSize, setFetchSize, updateBean, updateBeans, upsertBean, upsertBeansMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.synchronoss.cpo.core.CpoAdapter
deleteBean, deleteBean, deleteBeans, deleteBeans, executeBean, executeBean, existsBean, existsBean, insertBean, insertBean, insertBeans, insertBeans, retrieveBean, retrieveBean, retrieveBeans, retrieveBeans, retrieveBeans, updateBean, updateBean, updateBeans, updateBeans, upsertBean, upsertBean, upsertBeans, upsertBeans
-
Method Details
-
getInstance
public static JdbcCpoAdapter getInstance(JdbcCpoMetaDescriptor metaDescriptor, DataSourceInfo<DataSource> jdsiTrx) throws CpoException Finds or Creates a JdbcCpoAdapter.- Parameters:
metaDescriptor- - The meta descriptor for the datasourcejdsiTrx- - The datasurce info- Returns:
- A JdbcCpoAdapter
- Throws:
CpoException- - An error occurred finding of creating the datasource adapter
-
getInstance
public static JdbcCpoAdapter getInstance(JdbcCpoMetaDescriptor metaDescriptor, DataSourceInfo<DataSource> jdsiWrite, DataSourceInfo<DataSource> jdsiRead) throws CpoException Creates a JdbcCpoAdapter.- Parameters:
metaDescriptor- This datasource that identifies the cpo metadata datasourcejdsiWrite- The datasource that identifies the transaction database for write transactions.jdsiRead- The datasource that identifies the transaction database for read-only transactions.- Returns:
- - A JdbcCpoAdapter
- Throws:
CpoException- exception
-
existsBean
Description copied from class:CpoBaseAdapterThe 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 CpoAdapter(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(Logical.NONE, id, Comparison.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:
existsBeanin interfaceCpoAdapter- Specified by:
existsBeanin classCpoBaseAdapter<DataSource>- Type Parameters:
T- The type of the JavaBean- Parameters:
query- The function group and clauses to applybean- 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.- 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
-
newWhere
Description copied from interface:CpoAdapterCreates an empty CpoWhere.CpoWhere where = cpo.newWhere();- Specified by:
newWherein interfaceCpoAdapter- Overrides:
newWherein classCpoBaseAdapter<DataSource>- Returns:
- A CpoWhere
-
newWhere
Description copied from interface:CpoAdapterCreates a CpoWhere comparing the attribute to the value.CpoWhere where = cpo.newWhere(Logical.NONE, "id", Comparison.EQ, 42);- Specified by:
newWherein interfaceCpoAdapter- Overrides:
newWherein classCpoBaseAdapter<DataSource>- Type Parameters:
T- The type of the value- Parameters:
logical- How this where combines with the preceding where (AND, OR, NONE)attr- The metadata attribute name to constraincomp- The comparison operatorvalue- The value to compare against- Returns:
- A CpoWhere
-
newWhere
Description copied from interface:CpoAdapterCreates a CpoWhere comparing the attribute to the value, optionally negated.- Specified by:
newWherein interfaceCpoAdapter- Overrides:
newWherein classCpoBaseAdapter<DataSource>- Type Parameters:
T- The type of the value- Parameters:
logical- How this where combines with the preceding where (AND, OR, NONE)attr- The metadata attribute name to constraincomp- The comparison operatorvalue- The value to compare againstnot- true to negate the comparison- Returns:
- A CpoWhere
-
getCpoMetaDescriptor
Description copied from interface:CpoAdapterGet the CpoMetaDescriptor- Returns:
- The CpoMetaDescriptor
-
getCpoAttributes
Description copied from interface:CpoAdapterGets theCpoAttributedefinitions matching a comma-separated expression of attribute names, as declared in the meta data for this bean's class.- Parameters:
expression- An expression defining the CpoAttributes that you want- Returns:
- A list of CpoAttributes
- Throws:
CpoException- Thrown if there are errors accessing the datasource
-