Class CategoryQuery

java.lang.Object
com.avoka.tm.query.CategoryQuery

public class CategoryQuery extends Object

Provides a category value object query class.

Examples

Please find the category query examples of listValues and listJson below.

Category Query List Example

This Groovy example shows how to list categories sorted by name, with the result set limited to a maximum of 50 records.

 import com.avoka.tm.query.*
 import com.avoka.tm.vo.*
 

List categories = new CategoryQuery() .addOrderByAsc("name") .setFetchLimit(50) .listValues()

// In JSON format String json = new CategoryQuery() .addOrderByAsc("name") .setFetchLimit(50) .listJson()

Category Query First Example

This Groovy example shows how to get first category matching certain criteria.

 import com.avoka.tm.query.*
 import com.avoka.tm.vo.*
 

Category category = new CategoryQuery() .setId(1L) .firstValue()

//By name criteria Category category = new CategoryQuery() .setName("testName") .firstValue()

Category count query Example

This Groovy example shows how to count all categories.

 import com.avoka.tm.query.*
 

int count = new CategoryQuery() .count()

Since:
22.10.4
See Also:
  • Constructor Details

  • Method Details

    • setId

      public CategoryQuery setId(Long id)
      Set the category id (PK) query parameter.
      Parameters:
      id - the category id (PK) query parameter
      Returns:
      the category query
    • setName

      public CategoryQuery setName(String name)
      Set the name parameter.
      Parameters:
      name - the category name query parameter
      Returns:
      the category query
    • setClientCode

      public CategoryQuery setClientCode(String clientCode)
      set the category client code query parameter.
      Parameters:
      clientCode - the category client code query parameter
      Returns:
      the category query
    • setFetchLimit

      public CategoryQuery setFetchLimit(int fetchLimit)
      Set the query fetch limit to limit the maximum number of records returned. The default query fetch limit is 100 records.
      Parameters:
      fetchLimit - the query fetch limit
      Returns:
      the category query
    • addOrderByAsc

      public CategoryQuery addOrderByAsc(String orderProperty)
      Add the sort order by ascending to the query.
      Parameters:
      orderProperty - the property to sort by (required)
      Returns:
      the category query
    • addOrderByDesc

      public CategoryQuery addOrderByDesc(String orderProperty)
      Add the sort order by descending to the query.
      Parameters:
      orderProperty - the property to sort by (required)
      Returns:
      the category query
    • count

      public int count()
      Execute a select count query and return the total number of records selected by the query.
      Returns:
      Execute a select count query and return the total number of records selected by the query.
    • listValues

      public List<Category> listValues()
      Execute the category query and return a list of category value objects.
      Returns:
      Execute the category query and return a list of category value objects.
    • listJson

      public String listJson()
      Execute the query and return a category JSON array list.
      Returns:
      execute the query and return a category JSON array list.
    • firstValue

      public Category firstValue()
      Execute the query and return the first category value object for the query.
      Returns:
      execute the query and return the first category value object for the query.