Class CassandraCpoAdapter

All Implemented Interfaces:
Serializable, CpoAdapter

public class CassandraCpoAdapter extends CpoBaseAdapter<ClusterDataSource>
CassandraCpoAdapter is the Cassandra implementation of CpoAdapter, a set of routines that are responsible for managing value beans from a Cassandra datasource.
Author:
dberry
See Also:
  • Method Details

    • getInstance

      public static CassandraCpoAdapter getInstance(CassandraCpoMetaDescriptor metaDescriptor, DataSourceInfo<ClusterDataSource> cdsiTrx) throws CpoException
      Creates a CassandraCpoAdapter.
      Parameters:
      metaDescriptor - This datasource that identifies the cpo metadata datasource
      cdsiTrx - The datasource that identifies the transaction database for read and write transactions.
      Returns:
      The CassandraCpoAdapter
      Throws:
      CpoException - An exception occurred
    • getInstance

      public static CassandraCpoAdapter getInstance(CassandraCpoMetaDescriptor metaDescriptor, DataSourceInfo<ClusterDataSource> cdsiWrite, DataSourceInfo<ClusterDataSource> cdsiRead) throws CpoException
      Creates a CassandraCpoAdapter.
      Parameters:
      metaDescriptor - This datasource that identifies the cpo metadata datasource
      cdsiWrite - The datasource that identifies the transaction database for write transactions.
      cdsiRead - The datasource that identifies the transaction database for read-only transactions.
      Returns:
      The CassandraCpoAdapter
      Throws:
      CpoException - An exception occurred
    • existsBean

      public <T> long existsBean(CpoQuery query, T bean) throws CpoException
      Description copied from class: CpoBaseAdapter
      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 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:
      existsBean in interface CpoAdapter
      Specified by:
      existsBean in class CpoBaseAdapter<ClusterDataSource>
      Type Parameters:
      T - The type of the JavaBean
      Parameters:
      query - The function group and clauses to apply
      bean - 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
    • getCpoMetaDescriptor

      public CpoMetaDescriptor getCpoMetaDescriptor()
      getCpoMetaDescriptor returns the CpoMetaDescriptor associated with this CpoAdapter
      Returns:
      The CpoMetaDescriptor
    • getCpoAttributes

      public List<CpoAttribute> getCpoAttributes(String expression) throws CpoException
      Get the cpo attributes for this expression
      Parameters:
      expression - A string expression
      Returns:
      A List of CpoAttribute
      Throws:
      CpoException - An exception occurred