Package net.sf.basedb.core
Class AbstractEntityQuery
java.lang.Object
net.sf.basedb.core.AbstractQuery
net.sf.basedb.core.AbstractHqlQuery
net.sf.basedb.core.AbstractEntityQuery
- All Implemented Interfaces:
EntityQuery
,HqlQuery
,Query
- Direct Known Subclasses:
DataQuery
,ItemQuery
,ReporterScoreQuery
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
.
- Version:
- 2.0
- Author:
- Nicklas
- Last modified
- $Date: 2017-05-22 14:35:27 +0200 (må, 22 maj 2017) $
-
Field Summary
Modifier and TypeFieldDescriptionprivate static final boolean
So we don't always have to call logParam.debug()private QueryRuntimeFilterManager
The manager of the runtime query filters.Flags specifying which items to include.private static final org.slf4j.Logger
Log all parameter bindings to prepared statement.private final QueryRuntimeFilter
Optional runtime filter.private Permission
The logged in user's permission on the items.private final QueryRuntimeFilter
The required runtime filter.private final Item
The item type returned by the query, eg.private final Item
The root item type we start with in the query. eq. -
Constructor Summary
ConstructorDescriptionAbstractEntityQuery
(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.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. -
Method Summary
Modifier and TypeMethodDescriptionlong
Count the number of items/rows that are returned by the query.(package private) void
Disable all enabled runtime query filters for the query.(package private) void
Enable runtime query filters for the query.void
exclude
(Collection<Include> includes) void
Specify options for which items to exclude from the result.The logged in user's permission on the items returned by this query.The type of items the query returns.Get the type of query.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.Execute the query and return the ID values of all items matching the query.void
include
(Collection<Include> includes) void
Specify options for which items to include in the result.boolean
isIncluded
(Collection<Include> includes) boolean
isIncluded
(Include... includes) Check which options are set for the items to include in the resultvoid
Not supported.void
selectPermanent
(Select select) Not supported.void
setAutoJoinType
(JoinType joinType) Specify the join type of automatic joins.void
setIncludes
(Collection<Include> includes) Clears the lists of includes and adds a new collection.void
setItemPermission
(Permission permission) Only return items which the logged in user has the specified permission for.Methods inherited from class net.sf.basedb.core.AbstractHqlQuery
getCountHqlQuery, getIdHqlQuery, getMainHqlQuery, getRootAlias, isCachingResult, isReadonly, isStateless, postProcessQuery, reset, setCacheResult, setEntityParameter, setPermanentEntityParameter
Methods inherited from class net.sf.basedb.core.AbstractQuery
addAutoJoiner, getCountQuery, getFirstResult, getIdQuery, getMainQuery, getMaxResults, getParameterNames, getParameters, getParameterType, getParameterValue, getPermanentSelects, getQueryParameter, getQuerySection, getSelects, hasParameterValue, isCounting, isDistinct, isFailSafe, isReturningTotalCount, join, joinPermanent, order, orderPermanent, resetTemporary, restrict, restrictPermanent, setCounting, setDistinct, setFailSafe, setFirstResult, setMaxResults, setParameter, setPermanentParameter, setReturnTotalCount, temporaryJoin, temporarySelect, toQl, toString
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.HqlQuery
isCachingResult, setCacheResult, setEntityParameter, setPermanentEntityParameter
Methods inherited from interface net.sf.basedb.core.query.Query
addAutoJoiner, getFirstResult, getMaxResults, getParameterNames, getQueryParameter, getQuerySection, getRootAlias, hasParameterValue, isCounting, isDistinct, isFailSafe, isReadonly, isReturningTotalCount, join, joinPermanent, order, orderPermanent, reset, restrict, restrictPermanent, setDistinct, setFailSafe, setFirstResult, setMaxResults, setParameter, setPermanentParameter, setReturnTotalCount, toQl
-
Field Details
-
logParam
private static final org.slf4j.Logger logParamLog all parameter bindings to prepared statement. -
debugEnabled
private static final boolean debugEnabledSo we don't always have to call logParam.debug() -
returnType
The item type returned by the query, eg. SELECT [returnType] FROM ... -
rootType
The root item type we start with in the query. eq. SELECT ... FROM [rootTypeTable]- Since:
- 2.8
-
requiredFilter
The required runtime filter. -
optionalFilter
Optional runtime filter. -
filterManager
The manager of the runtime query filters. -
includes
Flags specifying which items to include. -
permission
The logged in user's permission on the items.
-
-
Constructor Details
-
AbstractEntityQuery
Create a new query returning items of the specified item type using the default optional runtime filter.- Parameters:
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 used
-
AbstractEntityQuery
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.- Parameters:
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 filter (not supported for stateless sessions)
-
AbstractEntityQuery
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.- Since:
- 2.8
- See Also:
-
-
Method Details
-
select
Not supported.- Specified by:
select
in interfaceQuery
- Overrides:
select
in classAbstractQuery
- Parameters:
select
- The query element to add- Throws:
UnsupportedOperationException
- Always- See Also:
-
selectPermanent
Not supported.- Specified by:
selectPermanent
in interfaceQuery
- Overrides:
selectPermanent
in classAbstractQuery
- Parameters:
select
- The query element to add- Throws:
UnsupportedOperationException
- Always- See Also:
-
group
Not supported.- Specified by:
group
in interfaceQuery
- Overrides:
group
in classAbstractQuery
- Parameters:
expression
- The query element to add- Throws:
UnsupportedOperationException
- Always- See Also:
-
groupPermanent
Not supported.- Specified by:
groupPermanent
in interfaceQuery
- Overrides:
groupPermanent
in classAbstractQuery
- Parameters:
expression
- The query element to add- Throws:
UnsupportedOperationException
- Always- See Also:
-
having
Not supported.- Specified by:
having
in interfaceQuery
- Overrides:
having
in classAbstractQuery
- Parameters:
restriction
- The query element to add- Throws:
UnsupportedOperationException
- Always- See Also:
-
havingPermanent
Not supported.- Specified by:
havingPermanent
in interfaceQuery
- Overrides:
havingPermanent
in classAbstractQuery
- Parameters:
restriction
- The query element to add- Throws:
UnsupportedOperationException
- Always- See Also:
-
getQueryType
Description copied from interface:Query
Get the type of query. Ie. The query language.- Specified by:
getQueryType
in interfaceQuery
- Overrides:
getQueryType
in classAbstractHqlQuery
- Returns:
QueryType.HQL
-
count
Description copied from interface:Query
Count the number of items/rows that are returned by the query. The method ignores theQuery.getFirstResult()
andQuery.getMaxResults()
settings.- Specified by:
count
in interfaceQuery
- Overrides:
count
in classAbstractHqlQuery
- Returns:
- The number of rows/items returned by the query
- Throws:
BaseException
- If there is an error
-
getItemType
Description copied from interface:EntityQuery
The type of items the query returns.- Specified by:
getItemType
in interfaceEntityQuery
-
getRootType
Description copied from interface:EntityQuery
The type of items that is the root of the query. In most cases, this is the same as theEntityQuery.getItemType()
, but not always.- Specified by:
getRootType
in interfaceEntityQuery
- Since:
- 2.8
-
include
Description copied from interface:EntityQuery
Specify options for which items to include in the result.- Specified by:
include
in interfaceEntityQuery
- Parameters:
includes
- An array of items that should be included- See Also:
-
include
- Specified by:
include
in interfaceEntityQuery
- See Also:
-
setIncludes
Description copied from interface:EntityQuery
Clears the lists of includes and adds a new collection.- Specified by:
setIncludes
in interfaceEntityQuery
- Parameters:
includes
- The new includes to be hold in the list.- Since:
- 2.14.2
- See Also:
-
exclude
Description copied from interface:EntityQuery
Specify options for which items to exclude from the result.- Specified by:
exclude
in interfaceEntityQuery
- Parameters:
excludes
- An array of options that should be excluded- See Also:
-
exclude
- Specified by:
exclude
in interfaceEntityQuery
- See Also:
-
isIncluded
Description copied from interface:EntityQuery
Check which options are set for the items to include in the result- Specified by:
isIncluded
in interfaceEntityQuery
- Parameters:
includes
- The options to check- Returns:
- TRUE If all specified options are included, FALSE otherwise
-
isIncluded
- Specified by:
isIncluded
in interfaceEntityQuery
- See Also:
-
setItemPermission
Description copied from interface:EntityQuery
Only return items which the logged in user has the specified permission for. The default is to return all items which the user has at least read permission for.- Specified by:
setItemPermission
in interfaceEntityQuery
- Parameters:
permission
- The required permission
-
getItemPermission
Description copied from interface:EntityQuery
The logged in user's permission on the items returned by this query.- Specified by:
getItemPermission
in interfaceEntityQuery
- Returns:
- A Permission object
-
idList
Description copied from interface:EntityQuery
Execute the query and return the ID values of all items matching the query.- Specified by:
idList
in interfaceEntityQuery
- Parameters:
dc
- TheDbControl
used to access the database and check permissions
-
setAutoJoinType
Specify the join type of automatic joins. The default join type isJoinType.LEFT
. This setting doesn't affect joins that has been made directly to the query.- Parameters:
joinType
- The type of the automatic joins- Since:
- 2.8
-
enableFilters
Enable runtime query filters for the query.- See Also:
-
disableFilters
Disable all enabled runtime query filters for the query.- See Also:
-