Modifiers

Query Modifiers

The following methods alters the behavior of the executed query, some can be a life saver, so check them all out.

c.timeout( 5000 )
c.readOnly(true)
c.firstResult(20).maxResults(50).fetchSize(10).cacheRegsion('my.awesome.region')
c.cache(true,'my.region')
c.order('lastName','desc',true);

newCriteria()
	 .eq( "this", value )
	 .peek( function(criteria){
	 	systemOutput( "CurrentSQL: #criteria.getSQLLog()#" )
	 })
	 .when( !isNull( arguments.published ), function( c ){
		c.eq( "isPublished", published )
	 })
	 .list();

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_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

Last updated