public long count ( Class < ? extends Execution > cls , Map < String , Object > criteria ) throws PersistenceException { logger . debug ( "enter - count(Class,Map)" ) ; if ( logger . isDebugEnabled ( ) ) { logger . debug ( "For: " + cache . getTarget ( ) . getName ( ) + "/" + cls + "/" + criteria ) ; } try { Transaction xaction = Transaction . getInstance ( true ) ; try { long count = 0L ; criteria = xaction . execute ( cls , criteria ) ; count = ( ( Number ) criteria . get ( "count" ) ) . longValue ( ) ; xaction . commit ( ) ; return count ; } finally { xaction . rollback ( ) ; } } finally { logger . debug ( "exit - count(Class,Map)" ) ; } }
Counts the number of items matching an arbitrary query . This method expects the passed in query to have one field called count in the map it returns . Anything else is ignored