Business Entity Count Method

Counting Query Results in Business Entities

Counting Query Results is a core feature of a Business Entity. It is implemented in the CountResultRecords Business Entity method and uses the CountResultRecords method of Data Access objects. The Business Entity also implements the counting mechanism according to the 'CCSBE01' specification, in which, a caching of the results is provided in order to optimize the performance.
The parameter object Consultingwerk.OERA.CountRecordsRequest of the CountResultRecords method extends the normal FetchDataRequest object with the following properties:

  • StopAfterNumResults (INPUT): The number of results that should be returned to the frontend as a "magic number", if no exact result can be returned due to the StopAfter Settings (default property of the FetchDataRequest)
  • NumResults (OUTPUT): The number of query results (or the "magic number" from (StopAfterNumResults) )
  • ExactResult (OUTPUT): Indicates whether the result could be determined or whether a cached value (see below) or the magic number was used

The Count Web Handler of the SmartComponent Library

The CountWebHandler was specifically implemented for the requirements of the JSDO and the Kendo UI Grid component. The parameters in the CountRecordsRequest are set to the following defaults:

  • StopAfter: 1 - that is, abort counting in the DataAccess class after one second
  • StopAfterNumResults: 9999 - as the Magic Number. In the future, we are considering making the Magic Number configurable on both the back end and the front end. To be able to rule out the conflict with the unlikely event of exactly 9999 result sets.

The CountWebHandler represents a special implementation of access to the count method. Even though the filter is given as a Read Request within the query string, in reality it is a PUT Verb method.

Caching the Count's Results

The caching of the Count Results is implemented within the Consultingwerk.OERA.ICountResultsCache / Consultingwerk.OERA.CountResultsCache Service.
The class "remembers" the result per business entity and query string. The storage time (caching), can be controlled via the .applicationsetting / .restapplicationsettings parameter CountResultsCacheMaxAge. Typical, our default setup value is 3600 (seconds = 1 hour). In the absence of no setting having been provided, then the code internally assumes a value of one minute (60 seconds).
If the service is not loaded, it will not be cached either.

Saving results in the cache 

If no previous result has been cached, and the business entity (or the data access object) is required to perform the 'Count' method, then providing the 'Count Query' took more than 100 msec, the result shall always be cached. However, 'Fast Count Queries' (calculation time less than 100 msec) are NEVER cached.

Registering the Business Entity Count Configuration within the '.applicationsetting / .restapplicationsettings' configuration file

Below are the configuration options for Count Caching:

 "CountFunctionJsonCatalogType": "count", 
 "CountResultsCacheMaxAge": "3600",