Interface Query
- All Known Subinterfaces:
- RelationQuery
- All Known Implementing Classes:
- AbstractHibernateQueryAdapter,- AbstractOrderableQuery,- AbstractRelationQueryAdapter,- EmptyQuery,- HibernateQueryAdapter,- ToManyRelationQueryAdapter,- ToOneRelationQueryAdapter
- 
Nested Class SummaryNested Classes
- 
Method SummaryModifier and TypeMethodDescriptionappendOrder(Ordering order) Append the givenOrderingpolicy to the existing ordering policy of this query.intcount()Currently badly implemented! Count the results.execute()Execute the query inQuery.Mode.LAZYmode using the default limit.execute(int limit) Deprecated.execute(int limit, Query.Mode mode) Deprecated.execute(Pagination pagination) Execute the query using the specified pagination parameters inQuery.Mode.LAZYmode.execute(Pagination pagination, Query.Mode mode) Execute the query using the specified pagination parameters in the specifiedQuery.Mode.execute(Query.Mode mode) Execute the query in the specifiedQuery.Modeusing the default limit.Executes and returns the first selected Entity by this query, or throws.@Nullable EntityExecutes and returns the first selected Entity by this query, or null if none.default PrimaryKey[]getKeys()Returns pks with no limitdefault PrimaryKey[]getKeys(Pagination pagination) Returns pks within given paginationGet the entity manager.Executes and returns the single selected Entity by this query, or throws.getOnlyResult(LockMode lockMode) @Nullable EntityExecutes and returns the single selected Entity by this query, or null if none, or throws.@Nullable EntitygetOnlyResultOrNull(LockMode lockMode) Get a reference to theOrderingpolicy of this query.booleanCheck whether this query has an ordering policy already.prependOrder(Ordering order) Prepend the givenOrderingpolicy to the existing ordering policy of this query.voidsetParameter(String name, Object value) Set a parameter for the query.Deprecated.usegetOnlyResult()@Nullable EntityDeprecated.usegetOnlyResultOrNull()()}Replace theOrderingpolicy of this query with the given ordering policy.
- 
Method Details- 
setParameterSet a parameter for the query.- Parameters:
- name- The name of the parameter
- value- The value of the parameter in the correct data type.
- Throws:
- PersistException- If the parameter cannot be set (invalid name, invalid value)
 
- 
getOrderingOrdering getOrdering()Get a reference to theOrderingpolicy of this query. If there currently is no ordering policy, one will be created.- Returns:
- The ordering policy of this query.
 
- 
hasOrderingboolean hasOrdering()Check whether this query has an ordering policy already.- Returns:
- true, if this query has an ordering policy with at least one rule,- falseif none or one without rules (which may mean that getOrdering() will make one up on the fly).
 
- 
withOrderReplace theOrderingpolicy of this query with the given ordering policy. If the given ordering policy is null or empty, it will be ignored and the existing ordering policy of the query will be preserved.- Returns:
- this query.
 
- 
prependOrderPrepend the givenOrderingpolicy to the existing ordering policy of this query.- Parameters:
- order- the ordering policy to prepend.
- Returns:
- this query.
 
- 
appendOrderAppend the givenOrderingpolicy to the existing ordering policy of this query.- Parameters:
- order- the ordering policy to append.
- Returns:
- this query.
 
- 
getKeysReturns pks with no limit- Returns:
- PKs of result entities.
 
- 
getKeysReturns pks within given pagination- Parameters:
- pagination- Limit and offset of result
- Returns:
- PKs of result entities.
 
- 
executeExecute the query inQuery.Mode.LAZYmode using the default limit.- Returns:
- The result of the query. To further process it use the EntityListsclass.
- Throws:
- PersistException- If an error occurs
 
- 
executeExecute the query in the specifiedQuery.Modeusing the default limit.- Parameters:
- mode- The query mode.
- Returns:
- The result of the query.
- Throws:
- PersistException- If an error occurs
 
- 
executeDeprecated.Execute the query using the specified limit inQuery.Mode.LAZYmode.- Parameters:
- limit- The maximum number of results, see class header (really).
- Returns:
- The result of the query.
- Throws:
- PersistException- If an error occurred.
 
- 
executeDeprecated.Execute the query using the specified limit in the specifiedQuery.Mode.- Parameters:
- limit- The maximum number of results, see class header (really).
- mode- The mode.
- Returns:
- The result of the query.
- Throws:
- PersistException- If an error occurred.
 
- 
executeExecute the query using the specified pagination parameters inQuery.Mode.LAZYmode.- Parameters:
- pagination- The offset and limit of the query.
- Returns:
- The result of the query.
 
- 
executeExecute 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.
 
- 
getOnlyResultEntity getOnlyResult()Executes and returns the single selected Entity by this query, or throws.- Returns:
- The single selected Entity.
- Throws:
- PermanentPersistException- If the query does not select exactly one Entity. Note that it does not matter if the model is to-1 or to-many.
- See Also:
 
- 
getOnlyResult
- 
uniqueResultDeprecated.usegetOnlyResult()Executes and returns the single selected Entity by this query, or throws.- Returns:
- The single selected Entity.
- Throws:
- PermanentPersistException- If the query does not select exactly one Entity. Note that it does not matter if the model is to-1 or to-many.
- PersistException
- See Also:
 
- 
getOnlyResultOrNullExecutes and returns the single selected Entity by this query, or null if none, or throws.- Returns:
- The single selected Entity, or nullif none.
- Throws:
- PermanentPersistException- If the query selects more than one Entity. Note that it does not matter if the model is to-1 or to-many.
- See Also:
 
- 
getOnlyResultOrNull
- 
uniqueResultOrNullDeprecated.usegetOnlyResultOrNull()()}Executes and returns the single selected Entity by this query, or null if none, or throws.- Returns:
- The single selected Entity, or nullif none.
- Throws:
- PermanentPersistException- If the query selects more than one Entity. Note that it does not matter if the model is to-1 or to-many.
- PersistException
- See Also:
 
- 
firstResultExecutes and returns the first selected Entity by this query, or throws.- Returns:
- The first selected Entity.
- Throws:
- PermanentPersistException- If the query does not select at least one Entity.
- PersistException
- See Also:
 
- 
firstResultOrNullExecutes and returns the first selected Entity by this query, or null if none.- Returns:
- The first selected Entity, or nullif none.
- Throws:
- PersistException- If an error occurred.
- See Also:
 
- 
countCurrently 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.
 
- 
getManagerEntityManager getManager()Get the entity manager.- Returns:
- The entity manager.
 
- 
toQueryDefinitionQueryDefinition toQueryDefinition()
 
- 
execute(Pagination)