public class EnhancedQueryCriteriaBean
extends java.lang.Object
Member Variable | Description |
Boolean distinctQuery |
If true, the query will only return distinct results. |
Boolean allVersions |
If true, the query will return all versions of an object. |
String queryType |
Specifies the type of query (read OR update). |
String [] table |
The tables that the query references, note: only queryType == read queries support multiple tables. |
EnhancedQueryQualificationSet whereClause |
Contains all qualifications to make query more specific, note: only queryType == read queries use this object. |
EnhancedObjectProperty [] attributes |
The contents of this array are determined by the queryType .
If the
Else, |
Currently Supports:
To Be Added:
Usage:
Table Name: SAMPLE_TABLEid | first_name | last_name | phone_number |
123 | John | Doe | 123-123-1234 |
QueryCriteriaBean
creation for SELECT
query: SELECT first_name, last_name FROM SAMPLE_TABLE WHERE id='123 AND phone_number='123-123-1234'
EnhancedQueryCriteriaBean readQueryBean = new EnhancedQueryCriteriaBean();
readQueryBean.setQueryType(OCConstants.READ_QUERY);
"SELECT first_name, last_name"
EnhancedObjectProperty
object for each of the SELECT attribute(s). setName()
: name of attribute column in the database table. setType()
: type of attribute. Valid parameters: OCConstants.TYPE_STRING, OCConstants.TYPE_BOOLEAN, etc. See OCConstants
class for details. EnhancedObjectProperty firstNameAttrProp = new EnhancedObjectProperty();
firstNameAttrProp.setName( "first_name" );
firstNameAttrProp.setType( OCConstants.TYPE_STRING );
EnhancedObjectProperty lastNameAttrProp = new EnhancedObjectProperty();
lastNameAttrProp.setName( "last_name" );
lastNameAttrProp.setType( OCConstants.TYPE_STRING );
EnhancedObjectProperty [] props = new EnhancedObjectProperty [2];
props[0] = firstNameAttrProp;
props[1] = lastNameAttrProp;
readQueryBean.setAttributes(props);
"FROM SAMPLE_TABLE"
setTable()
Set table property to an array of table name(s) in the SELECT clause.
readQueryBean.setTable(new String[]{"SAMPLE_TABLE"});
WHERE SAMPLE_TABLE.id='123' AND SAMPLE_TABLE.phone_number='123-123-1234'
EnhancedObjectProperty
object for each "table.a=b" in SELECT x FROM table WHERE table.a=b
setName()
: name of attribute column in the database table. setType()
: type of attribute. Valid parameters: OCConstants.TYPE_STRING, OCConstants.TYPE_BOOLEAN, etc. See OCConstants
class for details.setStrings()
: value of attribute, stored in the 0th index in a String array of size 1.setTableName()
: name of the repository table the the attribute belongs to.
EnhancedObjectProperty idAttrProp = new EnhancedObjectProperty();
idAttrProp.setName( "id" );
idAttrProp.setType( OCConstants.TYPE_STRING );
idAttrProp.setStrings( new String[] {"123"});
idAttrProp.setTableName("SAMPLE_TABLE");
EnhancedObjectProperty phone_numberAttrProp = new EnhancedObjectProperty();
phone_numberAttrProp.setName( "phone_number" );
phone_numberAttrProp.setType( OCConstants.TYPE_STRING );
phone_numberAttrProp.setStrings( new String[] {"123-123-1234"});
phone_numberAttrProp.setTableName("SAMPLE_TABLE");
EnhancedQueryQualificationBean
to complete each WHERE conditionsetProperty()
: an EnhancedObjectProperty
object containing a WHERE condition.setOperatorValue()
: logical operator for WHERE condition, eg. OCConstants.OPERATOR_EQUAL
, See #operatorValue
for acceptable values
EnhancedQueryQualificationBean readQualBean1 = new EnhancedQueryQualificationBean();
readQualBean1.setProperty(idAttrProp);
readQualBean1.setOperatorValue(OCConstants.OPERATOR_EQUAL);
EnhancedQueryQualificationBean readQualBean2 = new EnhancedQueryQualificationBean();
readQualBean2.setProperty(phone_numberAttrProp);
readQualBean2.setOperatorValue(OCConstants.OPERATOR_EQUAL);
EnhancedQueryQualificationSet
.qualificationBeans
: an array of EnhancedQueryQualificationBean
containing WHERE conditions.logicOperator
: Determines if all members of the set will be AND'ed together or OR'ed. Valid Parameters: AND, OR. EnhancedQueryQualificationSet readQualSet = new EnhancedQueryQualificationSet();
readQualSet.setQualificationBeans(new EnhancedQueryQualificationBean[]{readQualBean1,readQualBean2});
readQualSet.setLogicOperator("AND");
readQueryBean.setWhereClause(readQualSet);
QueryCriteriaBean
creation for UPDATE
query: UPDATE SAMPLE_TABLE SET first_name='Jane' WHERE id='123';
EnhancedQueryCriteriaBean updateQueryBean = new EnhancedQueryCriteriaBean();
updateQueryBean.setQueryType(OCConstants.UPDATE_QUERY);
"UPDATE SAMPLE_TABLE"
setTable()
Set table property to an array of table name(s) in the UPDATE clause.
updateQueryBean.setTable(new String[]{"SAMPLE_TABLE"});
SET first_name='Jane'
EnhancedObjectProperty
object for each of the UPDATE columns. setName()
: name of attribute column in the database table. setType()
: type of attribute. Valid parameters: OCConstants.TYPE_STRING, OCConstants.TYPE_BOOLEAN, etc. See OCConstants
class for details.setStrings()
: value to update, stored in the 0th index in a String array of size 1. EnhancedObjectProperty firstNameAttrProp = new EnhancedObjectProperty();
firstNameAttrProp.setName( "first_name" );
firstNameAttrProp.setType( OCConstants.TYPE_STRING );
firstNameAttrProp.setStrings(new String[] {"Jane"});
updateQueryBean.setAttributes(new EnhancedObjectProperty []{firstNameAttrProp} );
WHERE SAMPLE_TABLE.id='123'
EnhancedObjectProperty
object for each "table.a=b" in UPDATE table SET x=y WHERE table.a=b
setName()
: name of attribute column in the database table. setType()
: type of attribute. Valid parameters: OCConstants.TYPE_STRING, OCConstants.TYPE_BOOLEAN, etc. See OCConstants
class for details.setStrings()
: value of attribute, stored in the 0th index in a String array of size 1.setTableName()
: name of the repository table the the attribute belongs to.
EnhancedObjectProperty idAttrProp = new EnhancedObjectProperty();
idAttrProp.setName( "id" );
idAttrProp.setType( OCConstants.TYPE_STRING );
idAttrProp.setStrings( new String[] {"123"});
idAttrProp.setTableName("SAMPLE_TABLE");
EnhancedQueryQualificationBean
to complete each WHERE conditionsetProperty()
: an EnhancedObjectProperty
object containing a WHERE condition.setOperatorValue()
: logical operator for WHERE condition, eg. OCConstants.OPERATOR_EQUAL
, See #operatorValue
for acceptable values
EnhancedQueryQualificationBean updateQualBean = new EnhancedQueryQualificationBean();
updateQualBean.setProperty(idAttrProp);
updateQualBean.setOperatorValue(OCConstants.OPERATOR_EQUAL);
EnhancedQueryQualificationSet
.qualificationBeans
: an array of EnhancedQueryQualificationBean
containing WHERE conditions.logicOperator
: Determines if all members of the set will be AND'ed together or OR'ed. Valid Parameters: AND, OR. EnhancedQueryQualificationSet updateQualSet = new EnhancedQueryQualificationSet();
updateQualSet.setQualificationBeans(new EnhancedQueryQualificationBean[]{updateQualBean});
updateQualSet.setLogicOperator("AND");
updateQueryBean.setWhereClause(updateQualSet);
query: select t1.prop5, t2.prop6 from tableA t1, tableB t2 where ( (t1.prop1 = 1 AND t1.prop2=t2.prop3) OR (t1.prop1 = t2.prop3) )
Constructor and Description |
---|
EnhancedQueryCriteriaBean() |
Modifier and Type | Method and Description |
---|---|
boolean |
getAllVersions() |
EnhancedObjectProperty[] |
getAttributes() |
boolean |
getDistinctQuery() |
int |
getLimit() |
java.lang.String[] |
getOrderBy() |
java.lang.String |
getQueryType() |
java.lang.String[] |
getTable() |
EnhancedQueryQualificationSet |
getWhereClause() |
void |
setAllVersions(boolean allVersions) |
void |
setAttributes(EnhancedObjectProperty[] attributes) |
void |
setDistinctQuery(boolean distinctQuery) |
void |
setLimit(int limit) |
void |
setOrderBy(java.lang.String[] orderBy) |
void |
setQueryType(java.lang.String queryType)
Set query type
|
void |
setTable(java.lang.String[] table) |
void |
setWhereClause(EnhancedQueryQualificationSet whereClause) |
public boolean getDistinctQuery()
public void setDistinctQuery(boolean distinctQuery)
public boolean getAllVersions()
public void setAllVersions(boolean allVersions)
public java.lang.String getQueryType()
public void setQueryType(java.lang.String queryType)
queryType
- type of query, valid values:
public java.lang.String[] getTable()
public void setTable(java.lang.String[] table)
public EnhancedObjectProperty[] getAttributes()
attributes
public void setAttributes(EnhancedObjectProperty[] attributes)
public EnhancedQueryQualificationSet getWhereClause()
public void setWhereClause(EnhancedQueryQualificationSet whereClause)
public java.lang.String[] getOrderBy()
public void setOrderBy(java.lang.String[] orderBy)
public int getLimit()
public void setLimit(int limit)