|
2.9.1: 2008-12-18 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.basedb.core.AbstractQuery
net.sf.basedb.core.AbstractEntityQuery
abstract class AbstractEntityQuery
An abstract implementation of the EntityQuery
interface. This class
doesn't support adding selections, groups or having restrictions.
Include
options and permission control are implemented using
Hibernate filters. See QueryRuntimeFilterFactory
.
Field Summary | |
---|---|
private boolean |
cacheResults
If the results should be cached or not. |
private static boolean |
debugEnabled
So we don't always have to call logParam.debug() |
private QueryRuntimeFilterManager |
filterManager
The manager of the runtime query filters. |
private EnumSet<Include> |
includes
Flags specifying which items to include. |
private DbControl |
lastCountDc
The most recent DbControl used to execute the count query. |
private Query |
lastCountQuery
The most recent count query. |
private DbControl |
lastMainDc
The most recent DbControl used to execute the main query. |
private Query |
lastMainQuery
The most recent main query. |
private static Logger |
logParam
Log all parameter bindings to prepared statement. |
private QueryRuntimeFilter |
optionalFilter
Optional runtime filter. |
private Permission |
permission
The logged in user's permission on the items. |
private QueryRuntimeFilter |
requiredFilter
The required runtime filter. |
private Item |
returnType
The item type returned by the query, eg. |
private Item |
rootType
The root item type we start with in the query. eq. |
private boolean |
stateless
If the query should be executed in a stateless session or not. |
private static Set<Integer> |
ZERO_SET
|
Constructor Summary | |
---|---|
AbstractEntityQuery(Item returnType,
Item rootType,
String rootName,
String select,
boolean stateless,
QueryRuntimeFilter optionalFilter)
Create a new query that may have different return type and root item type. |
|
AbstractEntityQuery(Item returnType,
String entityName,
boolean stateless)
Create a new query returning items of the specified item type using the default optional runtime filter. |
|
AbstractEntityQuery(Item returnType,
String entityName,
boolean stateless,
QueryRuntimeFilter optionalFilter)
Create a new query returning items of the specified type with a non-default optional runtime filter. |
Method Summary | |
---|---|
long |
count(DbControl dc)
Count the number of items/rows that are returned by the query. |
(package private) void |
disableFilters(DbControl dc)
Disable all enabled runtime query filters for the query. |
(package private) void |
enableFilters(DbControl dc)
Enable runtime query filters for the query. |
void |
exclude(Collection<Include> includes)
|
void |
exclude(Include... excludes)
Specify options for which items to exclude from the result. |
(package private) Query |
getCountHqlQuery(DbControl dc)
Build the count query and set parameter values for it. |
Permission |
getItemPermission()
The logged in user's permission on the items returned by this query. |
Item |
getItemType()
The type of items the query returns. |
(package private) Query |
getMainHqlQuery(DbControl dc)
Build the main query and set parameter values for it. |
QueryType |
getQueryType()
Get the type of query. |
String |
getRootAlias()
The alias of the item that is the root of this query. |
Item |
getRootType()
The type of items that is the root of the query. |
void |
group(Expression expression)
Not supported. |
void |
groupPermanent(Expression expression)
Not supported. |
void |
having(Restriction restriction)
Not supported. |
void |
havingPermanent(Restriction restriction)
Not supported. |
void |
include(Collection<Include> includes)
|
void |
include(Include... includes)
Specify options for which items to include in the result. |
boolean |
isCachingResult()
If the query results are cached or not. |
boolean |
isIncluded(Collection<Include> includes)
|
boolean |
isIncluded(Include... includes)
Check which options are set for the items to include in the result |
boolean |
isReadonly()
If this query is readonly and cannot be structurally modified. |
protected boolean |
isStateless()
If queries are using the stateless Hibernate session or the regular session. |
void |
reset()
Reset all non-permanent query elements of the query and clear cached queries. |
void |
select(Select select)
Not supported. |
void |
selectPermanent(Select select)
Not supported. |
void |
setAutoJoinType(JoinType joinType)
Specify the join type of automatic joins. |
void |
setCacheResult(boolean flag)
Specify if the query results should be cached or not. |
void |
setItemPermission(Permission permission)
Only return items which the logged in user has the specified permission for. |
private void |
setParameters(Query query,
Map<String,QueryParameter> parameters)
Set parameter values on a query. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface net.sf.basedb.core.query.Query |
---|
addAutoJoiner, getFirstResult, getMaxResults, getParameterNames, getQueryParameter, getQuerySection, hasParameterValue, isCounting, isDistinct, isReturningTotalCount, join, joinPermanent, order, orderPermanent, restrict, restrictPermanent, setDistinct, setFirstResult, setMaxResults, setParameter, setPermanentParameter, setReturnTotalCount, toQl |
Field Detail |
---|
private static final Logger logParam
private static final boolean debugEnabled
private final Item returnType
private final Item rootType
private final boolean stateless
private final QueryRuntimeFilter requiredFilter
private final QueryRuntimeFilter optionalFilter
private QueryRuntimeFilterManager filterManager
private DbControl lastMainDc
private DbControl lastCountDc
private Query lastMainQuery
private Query lastCountQuery
private boolean cacheResults
private EnumSet<Include> includes
private Permission permission
private static final Set<Integer> ZERO_SET
Constructor Detail |
---|
AbstractEntityQuery(Item returnType, String entityName, boolean stateless)
returnType
- The type of items that are returnedentityName
- The name of the type of items as known to
Hibernate, or null to use the class of the return typestateless
- TRUE if the stateless Hibernate session should be used, FALSE
if the regular Hibernate session should be usedAbstractEntityQuery(Item returnType, String entityName, boolean stateless, QueryRuntimeFilter optionalFilter)
returnType
- The type of items that are returnedentityName
- The name of the type of items as known to
Hibernate, or null to use the class of the return typestateless
- TRUE if the stateless Hibernate session should be used, FALSE
if the regular Hibernate session should be usedoptionalFilter
- A runtime filter replacing the default optional filter
or null to not use any optional filterAbstractEntityQuery(Item returnType, Item rootType, String rootName, String select, boolean stateless, QueryRuntimeFilter optionalFilter)
DataQuery.DataQuery(Class, Item, String, String)
Method Detail |
---|
public void select(Select select)
select
in interface Query
select
in class AbstractQuery
select
- The query element to add
UnsupportedOperationException
- AlwaysQuery.selectPermanent(Select)
public void selectPermanent(Select select)
selectPermanent
in interface Query
selectPermanent
in class AbstractQuery
select
- The query element to add
UnsupportedOperationException
- AlwaysQuery.select(Select)
public void group(Expression expression)
group
in interface Query
group
in class AbstractQuery
expression
- The query element to add
UnsupportedOperationException
- AlwaysQuery.groupPermanent(Expression)
public void groupPermanent(Expression expression)
groupPermanent
in interface Query
groupPermanent
in class AbstractQuery
expression
- The query element to add
UnsupportedOperationException
- AlwaysQuery.group(Expression)
public void having(Restriction restriction)
having
in interface Query
having
in class AbstractQuery
restriction
- The query element to add
UnsupportedOperationException
- AlwaysQuery.havingPermanent(Restriction)
public void havingPermanent(Restriction restriction)
havingPermanent
in interface Query
havingPermanent
in class AbstractQuery
restriction
- The query element to add
UnsupportedOperationException
- AlwaysQuery.having(Restriction)
public QueryType getQueryType()
Query
getQueryType
in interface Query
QueryType.HQL
public String getRootAlias()
getRootAlias
in interface Query
Item.getAlias()
public boolean isReadonly()
Query
Query.reset()
would unlock the query and allow it to be modified again.
isReadonly
in interface Query
isReadonly
in class AbstractQuery
public void reset()
reset
in interface Query
reset
in class AbstractQuery
public long count(DbControl dc) throws BaseException
Query
Query.getFirstResult()
and Query.getMaxResults()
settings.
count
in interface Query
BaseException
- If there is an errorpublic void setCacheResult(boolean flag)
HqlQuery
setCacheResult
in interface HqlQuery
flag
- TRUE if the query results should be cached, FALSE otherwisepublic boolean isCachingResult()
HqlQuery
isCachingResult
in interface HqlQuery
HqlQuery.setCacheResult(boolean)
public Item getItemType()
EntityQuery
getItemType
in interface EntityQuery
public Item getRootType()
EntityQuery
EntityQuery.getItemType()
, but not
always.
getRootType
in interface EntityQuery
public void include(Include... includes)
EntityQuery
include
in interface EntityQuery
includes
- An array of items that should be includedEntityQuery.exclude(Include[])
public void include(Collection<Include> includes)
include
in interface EntityQuery
EntityQuery.include(Include[])
public void exclude(Include... excludes)
EntityQuery
exclude
in interface EntityQuery
excludes
- An array of options that should be excludedEntityQuery.include(Include[])
public void exclude(Collection<Include> includes)
exclude
in interface EntityQuery
EntityQuery.exclude(Include[])
public boolean isIncluded(Include... includes)
EntityQuery
isIncluded
in interface EntityQuery
includes
- The options to check
public boolean isIncluded(Collection<Include> includes)
isIncluded
in interface EntityQuery
EntityQuery.isIncluded(Include[])
public void setItemPermission(Permission permission)
EntityQuery
setItemPermission
in interface EntityQuery
permission
- The required permissionpublic Permission getItemPermission()
EntityQuery
getItemPermission
in interface EntityQuery
public void setAutoJoinType(JoinType joinType)
JoinType.LEFT
. This setting doesn't affect joins that has been made
directly to the the query.
joinType
- The type of the automatic joinsQuery getMainHqlQuery(DbControl dc)
DbControl
before and hasn't been reset()
the cached query is returned. If the parameters values have been changed the new
values are used.
dc
- The DbControl to use for executing the query
org.hibernate.Query
objectQuery getCountHqlQuery(DbControl dc)
DbControl
before and hasn't been reset()
the cached query is returned. If the parameters values have been changed the new
values are used.
dc
- The DbControl to use for executing the query
org.hibernate.Query
objectprotected boolean isStateless()
void enableFilters(DbControl dc)
disableFilters(DbControl)
void disableFilters(DbControl dc)
enableFilters(DbControl)
private void setParameters(Query query, Map<String,QueryParameter> parameters)
query
- The Hibernate query objectparameters
- A map containing parameter names and values
|
2.9.1: 2008-12-18 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |