Modifiers
Query Modifiers
The following methods alters the behavior of the executed query, some can be a life saver, so check them all out.
Method | Description |
| Tells Hibernate whether to cache the query or not (if the query cache is enabled), and optionally choose a cache region |
| Tells Hibernate the cache region to store the query under |
| Add a comment to the generated SQL. |
| Set's the fetch size of the underlying JDBC query |
| Specifies the offset for the results. A value of 0 will return all records up to the maximum specified. |
| Set a limit upon the number of objects to be retrieved. |
| Specifies both the sort property (the first argument, the sort order (either 'asc' or 'desc'), and if it should ignore cases or not |
| Peek into the criteria build process with your own closure that accepts the criteria itself. |
| Add a DB query hint to the SQL. These differ from JPA's QueryHint, which is specific to the JPA implementation and ignores DB vendor-specific hints. Instead, these are intended solely for the vendor-specific hints, such as Oracle's optimizers. Multiple query hints are supported; the Dialect will determine concatenation and placement. |
| Set the read-only/modifiable mode for entities and proxies loaded by this Criteria, defaults to |
| Set a timeout for the underlying JDBC query in milliseconds. |
| A nice functional method to allow you to pass a boolean evaulation and if true, the target closure will be executed for you, which will pass in the criteria object to it. |
Result Modifiers
You can also tell Hibernate to transform the results to other formats for you once you retrieve them.
asDistinct()
- Applies a result transformer of DISTINCT_ROOT_ENTITYasStruct()
- Applies a result transformer of ALIAS_TO_ENTITY_MAP so you get an array of structs instead of array of objectsasStream()
- Get the results as a CBstream
Last updated