Package org.synchronoss.cpo.core
Interface CpoAdapter
- All Superinterfaces:
Serializable
- All Known Subinterfaces:
CpoTrxAdapter
- All Known Implementing Classes:
CassandraCpoAdapter,CpoBaseAdapter,JdbcCpoAdapter,JdbcCpoTrxAdapter,JdbcCpoXaAdapter
CpoAdapter is an interface for a set of routines that are responsible for Creating, Retrieving,
Updating, and Deleting (CRUD) value beans within a datasource.
CpoAdapter is an interface that acts as a common facade for different datasources. It is conceivable that an CpoAdapter can be implemented for JDBC, CSV, XML, LDAP, and more datasources.
Every operation exists in a canonical form taking a CpoQuery — which carries the
function group name and any run-time where constraints, orderings, and native expressions — plus
convenience forms for the common no-clause cases. Example:
CpoAdapter cpo = CpoAdapterFactoryManager.getCpoAdapter("myContext");
CpoWhere where = cpo.newWhere(Logical.NONE, "id", Comparison.EQ, 42);
try (Stream<SomeBean> beans =
cpo.retrieveBeans(CpoQuery.group("byId").where(where), criteria)) {
beans.forEach(...);
}
The examples on the methods below assume a cpo adapter obtained as above and a
SomeBean class mapped in the meta data.
- Author:
- david berry
-
Method Summary
Modifier and TypeMethodDescriptiondefault <T> longdeleteBean(String groupName, T bean) Removes the bean from the datasource using the named DELETE function group.<T> longdeleteBean(CpoQuery query, T bean) Removes the bean from the datasource using the query's DELETE function group.default <T> longdeleteBean(T bean) Removes the bean from the datasource using the default DELETE function group.default <T> longdeleteBeans(String groupName, List<T> beans) Removes the beans from the datasource using the named DELETE function group.default <T> longdeleteBeans(List<T> beans) Removes the beans from the datasource using the default DELETE function group.<T> longdeleteBeans(CpoQuery query, List<T> beans) Removes the beans from the datasource using the query's DELETE function group, batching where the datasource supports it.default <T> TexecuteBean(String groupName, T bean) Executes the named EXECUTE function group with the bean as both criteria and result.<T,C> T executeBean(CpoQuery query, C criteria, T result) Executes the EXECUTE function group identified by the query — typically a stored procedure — using the criteria bean to populate the IN arguments and the result bean type for the OUT arguments.default <T> TexecuteBean(T bean) Executes the default EXECUTE function group with the bean as both criteria and result.default <T> longexistsBean(String groupName, T bean) Checks whether beans matching the given bean exist, using the named EXIST function group.<T> longexistsBean(CpoQuery query, T bean) Checks whether beans matching the given bean exist in the datasource, using the query's EXIST function group and where constraints.default <T> longexistsBean(T bean) Checks whether beans matching the given bean exist, using the default EXIST function group.intGet the batch size for updating the datasourcegetCpoAttributes(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 CpoMetaDescriptorGet the name of the datasourceintGet the fetch size for the datasourcedefault <T> longinsertBean(String groupName, T bean) Creates the bean in the datasource using the named CREATE function group.<T> longinsertBean(CpoQuery query, T bean) Creates the bean in the datasource using the query's CREATE function group.default <T> longinsertBean(T bean) Creates the bean in the datasource using the default CREATE function group.default <T> longinsertBeans(String groupName, List<T> beans) Creates the beans in the datasource using the named CREATE function group.default <T> longinsertBeans(List<T> beans) Creates the beans in the datasource using the default CREATE function group.<T> longinsertBeans(CpoQuery query, List<T> beans) Creates the beans in the datasource using the query's CREATE function group, batching where the datasource supports it.newOrderBy(String attribute, boolean ascending) Creates a CpoOrderBy for the attribute and direction.newOrderBy(String attribute, boolean ascending, String function) Creates a CpoOrderBy applying a datasource function to the attribute.newOrderBy(String marker, String attribute, boolean ascending) Creates a CpoOrderBy bound to a marker within the expression.newOrderBy(String marker, String attribute, boolean ascending, String function) Creates a CpoOrderBy bound to a marker, applying a datasource function to the attribute.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.default <T> TretrieveBean(String groupName, T bean) Retrieves a single bean using the named RETRIEVE function group; the bean supplies the search criteria and receives the result.<T,C> T retrieveBean(CpoQuery query, C criteria, T result) Retrieves the first bean produced by the query's RETRIEVE function group, using separate criteria and result beans.<T> TretrieveBean(CpoQuery query, T bean) Retrieves a single bean from the datasource using the query's RETRIEVE function group, with the given bean supplying the search criteria and receiving the result.default <T> TretrieveBean(T bean) Retrieves a single bean using the default RETRIEVE function group; the bean supplies the search criteria and receives the result.default <C> Stream<C> retrieveBeans(String groupName, C criteria) Retrieves beans using the named LIST function group; the criteria bean type is also the result type.default <T,C> Stream <T> retrieveBeans(String groupName, C criteria, T result) Retrieves beans using the named LIST function group with separate criteria and result beans.default <C> Stream<C> retrieveBeans(CpoQuery query, C criteria) Retrieves beans from the datasource using the query's LIST function group; the criteria bean type is also the result type.<T,C> Stream <T> retrieveBeans(CpoQuery query, C criteria, T result) Retrieves beans from the datasource using the query's LIST function group, with separate criteria and result beans.voidsetBatchSize(int batchsize) set the batch size for updating the datasourcevoidsetFetchSize(int fetchSize) set the fetch size for the datasourcedefault <T> longupdateBean(String groupName, T bean) Updates the bean in the datasource using the named UPDATE function group.<T> longupdateBean(CpoQuery query, T bean) Updates the bean in the datasource using the query's UPDATE function group.default <T> longupdateBean(T bean) Updates the bean in the datasource using the default UPDATE function group.default <T> longupdateBeans(String groupName, List<T> beans) Updates the beans in the datasource using the named UPDATE function group.default <T> longupdateBeans(List<T> beans) Updates the beans in the datasource using the default UPDATE function group.<T> longupdateBeans(CpoQuery query, List<T> beans) Updates the beans in the datasource using the query's UPDATE function group, batching where the datasource supports it.default <T> longupsertBean(String groupName, T bean) Inserts or updates the bean using the named UPSERT function group.<T> longupsertBean(CpoQuery query, T bean) Inserts or updates the bean using the query's UPSERT function group: the EXIST function decides whether the CREATE or UPDATE function is executed.default <T> longupsertBean(T bean) Inserts or updates the bean using the default UPSERT function group.default <T> longupsertBeans(String groupName, List<T> beans) Inserts or updates the beans using the named UPSERT function group.default <T> longupsertBeans(List<T> beans) Inserts or updates the beans using the default UPSERT function group.<T> longupsertBeans(CpoQuery query, List<T> beans) Inserts or updates the beans using the query's UPSERT function group: for each bean the EXIST function decides whether the CREATE or UPDATE function is executed.
-
Method Details
-
insertBean
Creates the bean in the datasource using the query's CREATE function group. The assumption is that the bean does not exist in the datasource.SomeBean bean = new SomeBean(); bean.setId(1); bean.setName("SomeName"); cpo.insertBean(CpoQuery.group("createBean"), bean);- Type Parameters:
T- The type of the JavaBean- Parameters:
query- The function group and clauses to applybean- A bean defined within the metadata of the datasource- Returns:
- The number of beans created in the datasource
- Throws:
CpoException- Thrown if there are errors accessing the datasource
-
insertBeans
Creates the beans in the datasource using the query's CREATE function group, batching where the datasource supports it. This is an all-or-nothing transaction: if one bean fails, no beans are created.List<SomeBean> beans = List.of(bean1, bean2); long created = cpo.insertBeans(CpoQuery.group("createBean"), beans);- Type Parameters:
T- The type of the JavaBean- Parameters:
query- The function group and clauses to applybeans- The beans to create- Returns:
- The number of beans created in the datasource
- Throws:
CpoException- Thrown if there are errors accessing the datasource
-
insertBean
Creates the bean in the datasource using the default CREATE function group.cpo.insertBean(bean);- Type Parameters:
T- The type of the JavaBean- Parameters:
bean- A bean defined within the metadata of the datasource- Returns:
- The number of beans created in the datasource
- Throws:
CpoException- Thrown if there are errors accessing the datasource
-
insertBean
Creates the bean in the datasource using the named CREATE function group.cpo.insertBean("createBean", bean);- Type Parameters:
T- The type of the JavaBean- Parameters:
groupName- The CREATE function group name; null signifies the default groupbean- A bean defined within the metadata of the datasource- Returns:
- The number of beans created in the datasource
- Throws:
CpoException- Thrown if there are errors accessing the datasource
-
insertBeans
Creates the beans in the datasource using the default CREATE function group.cpo.insertBeans(beans);- Type Parameters:
T- The type of the JavaBean- Parameters:
beans- The beans to create- Returns:
- The number of beans created in the datasource
- Throws:
CpoException- Thrown if there are errors accessing the datasource
-
insertBeans
Creates the beans in the datasource using the named CREATE function group.cpo.insertBeans("createBean", beans);- Type Parameters:
T- The type of the JavaBean- Parameters:
groupName- The CREATE function group name; null signifies the default groupbeans- The beans to create- Returns:
- The number of beans created in the datasource
- Throws:
CpoException- Thrown if there are errors accessing the datasource
-
deleteBean
Removes the bean from the datasource using the query's DELETE function group. The assumption is that the bean exists in the datasource.SomeBean bean = new SomeBean(); bean.setId(1); cpo.deleteBean(CpoQuery.group("deleteBean"), bean);- Type Parameters:
T- The type of the JavaBean- Parameters:
query- The function group and clauses to applybean- A bean defined within the metadata of the datasource- Returns:
- The number of beans deleted from the datasource
- Throws:
CpoException- Thrown if there are errors accessing the datasource
-
deleteBeans
Removes the beans from the datasource using the query's DELETE function group, batching where the datasource supports it. This is an all-or-nothing transaction: if one bean fails, no beans are deleted.long deleted = cpo.deleteBeans(CpoQuery.group("deleteBean"), beans);- Type Parameters:
T- The type of the JavaBean- Parameters:
query- The function group and clauses to applybeans- The beans to delete- Returns:
- The number of beans deleted from the datasource
- Throws:
CpoException- Thrown if there are errors accessing the datasource
-
deleteBean
Removes the bean from the datasource using the default DELETE function group.cpo.deleteBean(bean);- Type Parameters:
T- The type of the JavaBean- Parameters:
bean- A bean defined within the metadata of the datasource- Returns:
- The number of beans deleted from the datasource
- Throws:
CpoException- Thrown if there are errors accessing the datasource
-
deleteBean
Removes the bean from the datasource using the named DELETE function group.cpo.deleteBean("deleteBean", bean);- Type Parameters:
T- The type of the JavaBean- Parameters:
groupName- The DELETE function group name; null signifies the default groupbean- A bean defined within the metadata of the datasource- Returns:
- The number of beans deleted from the datasource
- Throws:
CpoException- Thrown if there are errors accessing the datasource
-
deleteBeans
Removes the beans from the datasource using the default DELETE function group.cpo.deleteBeans(beans);- Type Parameters:
T- The type of the JavaBean- Parameters:
beans- The beans to delete- Returns:
- The number of beans deleted from the datasource
- Throws:
CpoException- Thrown if there are errors accessing the datasource
-
deleteBeans
Removes the beans from the datasource using the named DELETE function group.cpo.deleteBeans("deleteBean", beans);- Type Parameters:
T- The type of the JavaBean- Parameters:
groupName- The DELETE function group name; null signifies the default groupbeans- The beans to delete- Returns:
- The number of beans deleted from the datasource
- Throws:
CpoException- Thrown if there are errors accessing the datasource
-
updateBean
Updates the bean in the datasource using the query's UPDATE function group. The assumption is that the bean exists in the datasource.SomeBean bean = new SomeBean(); bean.setId(1); bean.setName("NewName"); cpo.updateBean(CpoQuery.group("updateBean"), bean);- Type Parameters:
T- The type of the JavaBean- Parameters:
query- The function group and clauses to applybean- A bean defined within the metadata of the datasource- Returns:
- The number of beans updated in the datasource
- Throws:
CpoException- Thrown if there are errors accessing the datasource
-
updateBeans
Updates the beans in the datasource using the query's UPDATE function group, batching where the datasource supports it. This is an all-or-nothing transaction: if one bean fails, no beans are updated.long updated = cpo.updateBeans(CpoQuery.group("updateBean"), beans);- Type Parameters:
T- The type of the JavaBean- Parameters:
query- The function group and clauses to applybeans- The beans to update- Returns:
- The number of beans updated in the datasource
- Throws:
CpoException- Thrown if there are errors accessing the datasource
-
updateBean
Updates the bean in the datasource using the default UPDATE function group.cpo.updateBean(bean);- Type Parameters:
T- The type of the JavaBean- Parameters:
bean- A bean defined within the metadata of the datasource- Returns:
- The number of beans updated in the datasource
- Throws:
CpoException- Thrown if there are errors accessing the datasource
-
updateBean
Updates the bean in the datasource using the named UPDATE function group.cpo.updateBean("updateBean", bean);- Type Parameters:
T- The type of the JavaBean- Parameters:
groupName- The UPDATE function group name; null signifies the default groupbean- A bean defined within the metadata of the datasource- Returns:
- The number of beans updated in the datasource
- Throws:
CpoException- Thrown if there are errors accessing the datasource
-
updateBeans
Updates the beans in the datasource using the default UPDATE function group.cpo.updateBeans(beans);- Type Parameters:
T- The type of the JavaBean- Parameters:
beans- The beans to update- Returns:
- The number of beans updated in the datasource
- Throws:
CpoException- Thrown if there are errors accessing the datasource
-
updateBeans
Updates the beans in the datasource using the named UPDATE function group.cpo.updateBeans("updateBean", beans);- Type Parameters:
T- The type of the JavaBean- Parameters:
groupName- The UPDATE function group name; null signifies the default groupbeans- The beans to update- Returns:
- The number of beans updated in the datasource
- Throws:
CpoException- Thrown if there are errors accessing the datasource
-
upsertBean
Inserts or updates the bean using the query's UPSERT function group: the EXIST function decides whether the CREATE or UPDATE function is executed.SomeBean bean = new SomeBean(); bean.setId(1); bean.setName("SomeName"); cpo.upsertBean(CpoQuery.group("upsertBean"), bean); // inserts or updates as needed- Type Parameters:
T- The type of the JavaBean- Parameters:
query- The function group and clauses to applybean- A bean defined within the metadata of the datasource- Returns:
- The number of beans upserted in the datasource
- Throws:
CpoException- Thrown if there are errors accessing the datasource, or if the EXIST function matches more than one record
-
upsertBeans
Inserts or updates the beans using the query's UPSERT function group: for each bean the EXIST function decides whether the CREATE or UPDATE function is executed.long upserted = cpo.upsertBeans(CpoQuery.group("upsertBean"), beans);- Type Parameters:
T- The type of the JavaBean- Parameters:
query- The function group and clauses to applybeans- The beans to upsert- Returns:
- The number of beans upserted in the datasource
- Throws:
CpoException- Thrown if there are errors accessing the datasource, or if the EXIST function matches more than one record
-
upsertBean
Inserts or updates the bean using the default UPSERT function group.cpo.upsertBean(bean);- Type Parameters:
T- The type of the JavaBean- Parameters:
bean- A bean defined within the metadata of the datasource- Returns:
- The number of beans upserted in the datasource
- Throws:
CpoException- Thrown if there are errors accessing the datasource, or if the EXIST function matches more than one record
-
upsertBean
Inserts or updates the bean using the named UPSERT function group.cpo.upsertBean("upsertBean", bean);- Type Parameters:
T- The type of the JavaBean- Parameters:
groupName- The UPSERT function group name; null signifies the default groupbean- A bean defined within the metadata of the datasource- Returns:
- The number of beans upserted in the datasource
- Throws:
CpoException- Thrown if there are errors accessing the datasource, or if the EXIST function matches more than one record
-
upsertBeans
Inserts or updates the beans using the default UPSERT function group.cpo.upsertBeans(beans);- Type Parameters:
T- The type of the JavaBean- Parameters:
beans- The beans to upsert- Returns:
- The number of beans upserted in the datasource
- Throws:
CpoException- Thrown if there are errors accessing the datasource, or if the EXIST function matches more than one record
-
upsertBeans
Inserts or updates the beans using the named UPSERT function group.cpo.upsertBeans("upsertBean", beans);- Type Parameters:
T- The type of the JavaBean- Parameters:
groupName- The UPSERT function group name; null signifies the default groupbeans- The beans to upsert- Returns:
- The number of beans upserted in the datasource
- Throws:
CpoException- Thrown if there are errors accessing the datasource, or if the EXIST function matches more than one record
-
existsBean
Checks whether beans matching the given bean exist in the datasource, using the query's EXIST function group and where constraints.CpoWhere where = cpo.newWhere(Logical.NONE, "id", Comparison.EQ, 1); long count = cpo.existsBean(CpoQuery.group("existsBean").where(where), bean); if (count > 0) { // the bean exists }- Type Parameters:
T- The type of the JavaBean- Parameters:
query- The function group and clauses to applybean- The bean to search for in the datasource- Returns:
- The number of beans that exist in the datasource that match the specified bean. An EXIST function must either return a count as a single row with a single numeric column (count(*) style) or return one row per matching bean; a single-row result with one numeric column is always interpreted as a count
- Throws:
CpoException- Thrown if there are errors accessing the datasource
-
existsBean
Checks whether beans matching the given bean exist, using the default EXIST function group.long count = cpo.existsBean(bean);- Type Parameters:
T- The type of the JavaBean- Parameters:
bean- The bean to search for in the datasource- Returns:
- The number of beans that exist in the datasource that match the specified bean
- Throws:
CpoException- Thrown if there are errors accessing the datasource
-
existsBean
Checks whether beans matching the given bean exist, using the named EXIST function group.long count = cpo.existsBean("existsBean", bean);- Type Parameters:
T- The type of the JavaBean- Parameters:
groupName- The EXIST function group name; null signifies the default groupbean- The bean to search for in the datasource- Returns:
- The number of beans that exist in the datasource that match the specified bean
- Throws:
CpoException- Thrown if there are errors accessing the datasource
-
executeBean
Executes the EXECUTE function group identified by the query — typically a stored procedure — using the criteria bean to populate the IN arguments and the result bean type for the OUT arguments.SomeResult result = cpo.executeBean(CpoQuery.group("calculateTotals"), criteria, new SomeResult());- Type Parameters:
T- The type of the result JavaBeanC- The type of the criteria JavaBean- Parameters:
query- The function group to executecriteria- A bean defined within the metadata of the datasource used to populate the IN argumentsresult- A bean defined within the metadata of the datasource that defines the bean type populated with the OUT arguments- Returns:
- A result bean populated with the OUT arguments
- Throws:
CpoException- Thrown if there are errors accessing the datasource
-
executeBean
Executes the default EXECUTE function group with the bean as both criteria and result.SomeBean result = cpo.executeBean(bean);- Type Parameters:
T- The type of the JavaBean- Parameters:
bean- The bean used for the IN arguments and populated with the OUT arguments- Returns:
- A result bean populated with the OUT arguments
- Throws:
CpoException- Thrown if there are errors accessing the datasource
-
executeBean
Executes the named EXECUTE function group with the bean as both criteria and result.SomeBean result = cpo.executeBean("calculateTotals", bean);- Type Parameters:
T- The type of the JavaBean- Parameters:
groupName- The EXECUTE function group name; null signifies the default groupbean- The bean used for the IN arguments and populated with the OUT arguments- Returns:
- A result bean populated with the OUT arguments
- Throws:
CpoException- Thrown if there are errors accessing the datasource
-
retrieveBean
Retrieves a single bean from the datasource using the query's RETRIEVE function group, with the given bean supplying the search criteria and receiving the result. If the function returns more than one row, an exception is thrown.SomeBean criteria = new SomeBean(); criteria.setId(1); SomeBean bean = cpo.retrieveBean(CpoQuery.group("retrieveBean"), criteria);- Type Parameters:
T- The type of the JavaBean- Parameters:
query- The function group and clauses to applybean- A bean defined within the metadata of the datasource whose attributes supply the search criteria- Returns:
- A populated bean of the same type as the bean passed in, or null if no beans match
- Throws:
CpoException- Thrown if there are errors accessing the datasource or more than one row is returned
-
retrieveBean
Retrieves the first bean produced by the query's RETRIEVE function group, using separate criteria and result beans.SomeResult result = cpo.retrieveBean(CpoQuery.group("retrieveResult"), criteria, new SomeResult());- Type Parameters:
T- The type of the result JavaBeanC- The type of the criteria JavaBean- Parameters:
query- The function group and clauses to applycriteria- A bean defined within the metadata of the datasource that supplies the retrieval parametersresult- A bean defined within the metadata of the datasource that specifies the returned bean type- Returns:
- A bean of the same type as the result parameter, or null if no beans match
- Throws:
CpoException- Thrown if there are errors accessing the datasource
-
retrieveBean
Retrieves a single bean using the default RETRIEVE function group; the bean supplies the search criteria and receives the result.SomeBean bean = cpo.retrieveBean(criteria);- Type Parameters:
T- The type of the JavaBean- Parameters:
bean- A bean defined within the metadata of the datasource whose attributes supply the search criteria- Returns:
- A populated bean of the same type as the bean passed in, or null if no beans match
- Throws:
CpoException- Thrown if there are errors accessing the datasource or more than one row is returned
-
retrieveBean
Retrieves a single bean using the named RETRIEVE function group; the bean supplies the search criteria and receives the result.SomeBean bean = cpo.retrieveBean("retrieveBean", criteria);- Type Parameters:
T- The type of the JavaBean- Parameters:
groupName- The RETRIEVE function group name; null signifies the default groupbean- A bean defined within the metadata of the datasource whose attributes supply the search criteria- Returns:
- A populated bean of the same type as the bean passed in, or null if no beans match
- Throws:
CpoException- Thrown if there are errors accessing the datasource or more than one row is returned
-
retrieveBeans
Retrieves beans from the datasource using the query's LIST function group, with separate criteria and result beans.CpoWhere where = cpo.newWhere(Logical.NONE, "dept", Comparison.EQ, "sales"); CpoOrderBy orderBy = cpo.newOrderBy("name", true); try (Stream<SomeResult> beans = cpo.retrieveBeans( CpoQuery.group("listResults").where(where).orderBy(orderBy), criteria, new SomeResult())) { beans.forEach(...); }- Type Parameters:
T- The type of the result JavaBeanC- The type of the criteria JavaBean- Parameters:
query- The function group and clauses to applycriteria- A bean defined within the metadata of the datasource that supplies the retrieval parametersresult- A bean defined within the metadata of the datasource that specifies the returned bean type- Returns:
- A stream of beans that meet the criteria; empty if none match. The stream is backed by open datastore resources (statement, result set, and connection) that are released only when the stream is closed; terminal operations do not close it. Always close the returned stream, preferably with try-with-resources.
- Throws:
CpoException- Thrown if there are errors accessing the datasource
-
retrieveBeans
Retrieves beans from the datasource using the query's LIST function group; the criteria bean type is also the result type.CpoWhere where = cpo.newWhere(Logical.NONE, "dept", Comparison.EQ, "sales"); try (Stream<SomeBean> beans = cpo.retrieveBeans(CpoQuery.group("listBeans").where(where), criteria)) { beans.forEach(...); }- Type Parameters:
C- The type of the criteria JavaBean- Parameters:
query- The function group and clauses to applycriteria- A bean defined within the metadata of the datasource that supplies the retrieval parameters- Returns:
- A stream of beans that meet the criteria; empty if none match. The stream is backed by open datastore resources (statement, result set, and connection) that are released only when the stream is closed; terminal operations do not close it. Always close the returned stream, preferably with try-with-resources.
- Throws:
CpoException- Thrown if there are errors accessing the datasource
-
retrieveBeans
Retrieves beans using the named LIST function group; the criteria bean type is also the result type.try (Stream<SomeBean> beans = cpo.retrieveBeans("listBeans", criteria)) { beans.forEach(...); }- Type Parameters:
C- The type of the criteria JavaBean- Parameters:
groupName- The LIST function group name; null signifies the default groupcriteria- A bean defined within the metadata of the datasource that supplies the retrieval parameters- Returns:
- A stream of beans that meet the criteria; empty if none match. Always close the returned stream, preferably with try-with-resources.
- Throws:
CpoException- Thrown if there are errors accessing the datasource
-
retrieveBeans
Retrieves beans using the named LIST function group with separate criteria and result beans.try (Stream<SomeResult> beans = cpo.retrieveBeans("listResults", criteria, new SomeResult())) { beans.forEach(...); }- Type Parameters:
T- The type of the result JavaBeanC- The type of the criteria JavaBean- Parameters:
groupName- The LIST function group name; null signifies the default groupcriteria- A bean defined within the metadata of the datasource that supplies the retrieval parametersresult- A bean defined within the metadata of the datasource that specifies the returned bean type- Returns:
- A stream of beans that meet the criteria; empty if none match. Always close the returned stream, preferably with try-with-resources.
- Throws:
CpoException- Thrown if there are errors accessing the datasource
-
newOrderBy
Creates a CpoOrderBy for the attribute and direction.CpoOrderBy byNameAscending = cpo.newOrderBy("name", true);- Parameters:
attribute- The metadata attribute name to order byascending- true for ascending, false for descending- Returns:
- A CpoOrderBy
- Throws:
CpoException- An error occurred creating the CpoOrderBy
-
newOrderBy
Creates a CpoOrderBy bound to a marker within the expression.- Parameters:
marker- The marker in the expression that this order-by replacesattribute- The metadata attribute name to order byascending- true for ascending, false for descending- Returns:
- A CpoOrderBy
- Throws:
CpoException- An error occurred creating the CpoOrderBy
-
newOrderBy
Creates a CpoOrderBy applying a datasource function to the attribute.- Parameters:
attribute- The metadata attribute name to order byascending- true for ascending, false for descendingfunction- A datasource function to apply to the attribute- Returns:
- A CpoOrderBy
- Throws:
CpoException- An error occurred creating the CpoOrderBy
-
newOrderBy
CpoOrderBy newOrderBy(String marker, String attribute, boolean ascending, String function) throws CpoException Creates a CpoOrderBy bound to a marker, applying a datasource function to the attribute.- Parameters:
marker- The marker in the expression that this order-by replacesattribute- The metadata attribute name to order byascending- true for ascending, false for descendingfunction- A datasource function to apply to the attribute- Returns:
- A CpoOrderBy
- Throws:
CpoException- An error occurred creating the CpoOrderBy
-
newWhere
Creates an empty CpoWhere.CpoWhere where = cpo.newWhere();- Returns:
- A CpoWhere
- Throws:
CpoException- An error occurred creating the CpoWhere
-
newWhere
Creates a CpoWhere comparing the attribute to the value.CpoWhere where = cpo.newWhere(Logical.NONE, "id", Comparison.EQ, 42);- 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
- Throws:
CpoException- An error occurred creating the CpoWhere
-
newWhere
<T> CpoWhere newWhere(Logical logical, String attr, Comparison comp, T value, boolean not) throws CpoException Creates a CpoWhere comparing the attribute to the value, optionally negated.- 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
- Throws:
CpoException- An error occurred creating the CpoWhere
-
getCpoMetaDescriptor
CpoMetaDescriptor getCpoMetaDescriptor()Get the CpoMetaDescriptor- Returns:
- The CpoMetaDescriptor
-
getDataSourceName
String getDataSourceName()Get the name of the datasource- Returns:
- The name of the datasource
-
getFetchSize
int getFetchSize()Get the fetch size for the datasource- Returns:
- The fetchsize
-
setFetchSize
void setFetchSize(int fetchSize) set the fetch size for the datasource- Parameters:
fetchSize- The fetchsize to set for retrieving data
-
getBatchSize
int getBatchSize()Get the batch size for updating the datasource- Returns:
- The batchsize
-
setBatchSize
void setBatchSize(int batchsize) set the batch size for updating the datasource- Parameters:
batchsize- The batchsize for updating the datasource
-
getCpoAttributes
Gets 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
-