Class HibernateQueryAdapter
- All Implemented Interfaces:
Query
Query
interface.
Based on EntityQueryBuilder
, SinglePathQueryBuilder
(for Query.getKeys()
) and CountQueryBuilder
instances.-
Nested Class Summary
Nested classes/interfaces inherited from interface ch.tocco.nice2.persist.core.api.query.Query
Query.Mode
-
Field Summary
Fields inherited from class ch.tocco.nice2.persist.core.impl.hibernate.pojo.AbstractHibernateQueryAdapter
entityManager
Fields inherited from class ch.tocco.nice2.persist.core.spi.entity.query.ql.AbstractOrderableQuery
ordering
-
Constructor Summary
ConstructorDescriptionHibernateQueryAdapter
(PersistenceService persistenceService, EntityManager entityManager, List<Node> conditions, Ordering ordering, Map<String, ?> queryHints) HibernateQueryAdapter
(PersistenceService persistenceService, EntityManager entityManager, List<Node> conditions, List<Node> insecureConditions, Ordering ordering, Map<String, ?> queryHints) -
Method Summary
Modifier and TypeMethodDescriptionint
count()
Currently badly implemented! Count the results.execute
(Pagination pagination, Query.Mode mode) Execute the query using the specified pagination parameters in the specifiedQuery.Mode
.getKeys
(Pagination pagination) Returns pks within given pagination@Nullable Entity
getOnlyResultOrNull
(LockMode lockMode) void
setParameter
(String name, Object value) Set a parameter for the query.Methods inherited from class ch.tocco.nice2.persist.core.impl.hibernate.pojo.AbstractHibernateQueryAdapter
execute, execute, execute, execute, execute, firstResult, firstResultOrNull, getManager, getOnlyResult, getOnlyResult, getOnlyResultOrNull, uniqueResult, uniqueResultOrNull
Methods inherited from class ch.tocco.nice2.persist.core.spi.entity.query.ql.AbstractOrderableQuery
appendOrder, getOrdering, hasOrdering, prependOrder, withOrder
-
Constructor Details
-
HibernateQueryAdapter
public HibernateQueryAdapter(PersistenceService persistenceService, EntityManager entityManager, List<Node> conditions, Ordering ordering, Map<String, ?> queryHints) -
HibernateQueryAdapter
public HibernateQueryAdapter(PersistenceService persistenceService, EntityManager entityManager, List<Node> conditions, List<Node> insecureConditions, Ordering ordering, Map<String, ?> queryHints)
-
-
Method Details
-
setParameter
Description copied from interface:Query
Set a parameter for the query.- Parameters:
name
- The name of the parametervalue
- The value of the parameter in the correct data type.- Throws:
PersistException
- If the parameter cannot be set (invalid name, invalid value)
-
getKeys
Description copied from interface:Query
Returns pks within given pagination- Parameters:
pagination
- Limit and offset of result- Returns:
- PKs of result entities.
-
execute
Description copied from interface:Query
Execute the query using the specified pagination parameters in the specifiedQuery.Mode
.- Parameters:
pagination
- The offset and limit of the query.mode
- The mode.- Returns:
- The result of the query.
-
getOnlyResultOrNull
-
count
Description copied from interface:Query
Currently badly implemented! Count the results.WARNING: This method does not behave as "SELECT count()" in SQL does! In fact it is temporarily implemented as a chaining of execute().size() only. No query modification is done etc. ALSO, the default query limit is used and thus if there would be more records, only the default limit is returned. The impl may be rewritten to be what one would expect; until then users may only use this method if they can live with today's limits: small counts.
Speed of "SELECT count()" greatly depends on the underlying db table impl. An example are the two MySQL table types MyISAM and InnoDB. A query-less count on the former returns instantly because it keeps track of the number, whereas the latter needs to iterate over all records (at least in case of non-fixed length record tables) and can take minutes depending on the size.
- Returns:
- The count.
- Throws:
PersistException
- If an error occurs.
-
toQueryDefinition
-