public class DBQuery<TEntity extends IEntity> extends Object implements IDBQuery<TEntity>, IDBBackendQuery
YourDbEntity aEntity = new YourDbEntity ();
IDB iDb = iDbPool.getDbForPersistenceUnit ();
// If this is called the first time (you must not track that outside !)
// it creates a new query ...
// If its called the second time it reuses the internal cached query object.
// But it does not compile these query !
IDBQuery iQuery = iDb.prepareQuery ("YourQueryId");
// Then you can define your query attributes and values.
// If you call it the first time ... you do two things at the same time:
// a ) you define the structure of the query by adding new attribute names
// b ) you define the first set of query values by setting new values
//
// If you call it the second time ...
// a') we check if your attribute is still known on that query
// - in case it's not ... an exception is thrown
// - otherwise ...
// b') you define the set of query values by setting new values
// for existing attributes here
iQuery.setQueryPart (0, EQueryPartBinding.E_AND, EQueryPartOperation.E_MATCH, "your_attribute", your_value);
// If this is the first request for this query ...
// it will be compiled and executed then.
// If it is the second request for this query ...
// it wont be compiled ... but executed.
iDb.query(..., iQuery);
| Constructor and Description |
|---|
DBQuery() |
| Modifier and Type | Method and Description |
|---|---|
void |
bindToQueryTemplate(DBQueryTemplate<TEntity> aTemplate)
bind this query instance to it's template where all meta information exists.
|
String |
getId() |
int |
getPartCount() |
QueryPartValue[] |
getQueryParts()
provides read access to the different parts of this query.
|
DBQueryTemplate<TEntity> |
getTemplate() |
void |
setQueryPart(int nPosition,
EQueryPartBinding eBinding,
EQueryPartOperation eOperation,
String sAttribute,
Object aValue)
define one part of the query ...
|
public void bindToQueryTemplate(DBQueryTemplate<TEntity> aTemplate)
aTemplate - [IN]
the template where this query is bound to.public DBQueryTemplate<TEntity> getTemplate() throws Exception
Exceptionpublic void setQueryPart(int nPosition,
EQueryPartBinding eBinding,
EQueryPartOperation eOperation,
String sAttribute,
Object aValue)
throws Exception
IDBQuerysetQueryPart in interface IDBQuery<TEntity extends IEntity>nPosition - [IN]
the position of that part within the query.
Must start at 0.eBinding - [IN]
define the boolean operator (and/or) against the part
placed at nPosition-1.
Will be ignored if nPosition==0.eOperation - [IN]
define the operation used by this part (==, like, between ...)sAttribute - [IN]
the name of the attribute to be checked here.aValue - [IN]
the search value itself.
Note For the given value there exists some conditions ...
a) if eOperation=like it must be from type String.
b) if eOperation=between it must be from type BetweenQueryRange.Exceptionpublic QueryPartValue[] getQueryParts() throws Exception
IDBBackendQuerygetQueryParts in interface IDBBackendQueryExceptionCopyright © 2016 as-development.net. All rights reserved.