newCriteria()method. The corresponding class is:
cache()- Enable caching of this query result, provided query caching is enabled for the underlying session factory.
cacheRegion()- Set the name of the cache region to use for query result caching.
comment()- Add a comment to the generated SQL.
fetchSize()- Set a fetch size for the underlying JDBC query.
firstResult()- Set the first result to be retrieved or the offset integer
maxResults()- Set a limit upon the number of objects to be retrieved.
order()- Add an ordering to the result set, you can add as many as you like
queryHint()- 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.
readOnly()- Set the read-only/modifiable mode for entities and proxies loaded by this Criteria, defaults to readOnly=true
timeout()- Set a timeout for the underlying JDBC query in milliseconds.
asDistinct()- Applies a result transformer of DISTINCT_ROOT_ENTITY
asStruct()- Applies a result transformer of ALIAS_TO_ENTITY_MAP so you get an array of structs instead of array of objects
asStream()- Get the results as a CBstream
list()- Execute the criteria queries you have defined and return the results as an array of objects
get( [properties] )- Convenience method to return a single instance that matches the built up criterias query, or null if the query returns no results.
getOrFail( [properties] )- Convenience method to return a single instance that matches the built up criterias query, or throws an exception if the query returns no results
count()- Get the record count using hibernate projections for the given criterias
logSQL( label )- Allows for one-off sql logging at any point in the process of building up CriteriaBuilder; will log the SQL state at the time of the call
getSQL( returnExecutableSql = false, formatSql )- Returns the SQL string that will be prepared for the criteria object at the time of request. If you set returnExecutableSql to true , the SQL returned will include the parameters populated.
getPositionalSQLParameters()- Returns a formatted array of parameter value and types
getSqlLog()- Retrieves the SQL Log
startSqlLog()- Triggers CriteriaBuilder to start internally logging the state of SQL at each iterative build
stopSqlLog()- Stop the internal logging.
logSql()- Allows for one-off sql logging at any point in the process of building up CriteriaBuilder; will log the SQL state at the time of the call
canLogSql()- Returns whether or not CriteriaBuilder is currently configured to log SQL
peek( function/closure )- Used to peek into the criteria builder process. You pass in a closure/lambda that receives the criteria. You can then use it to peek into the sql or more.