Class ClientQuery

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

public class ClientQuery extends Object

Provides a client value object query class.

Examples

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

Client Query List Example

This Groovy example shows how to list clients 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<Client> clients = new ClientQuery()
     .addOrderByAsc("name")
     .setFetchLimit(50)
     .listValues()

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

Client Query First Example

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

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

 Client client = new ClientQuery()
     .setId(1L)
     .firstValue()

 //By name criteria
 Client client = new ClientQuery()
      .setName("testName")
      .firstValue() 

Client Query Count Example

This Groovy example shows how to count all clients.

 import com.avoka.tm.query.*

 int clientCount = new ClientQuery()
     .count()  
Since:
22.10.4
See Also:
  • Constructor Details

  • Method Details

    • setId

      public ClientQuery setId(Long id)
      Set the client id (PK) query parameter.
      Parameters:
      id - the client id (PK) query parameter
      Returns:
      the client query
    • setCode

      public ClientQuery setCode(String code)
      Set the client code query parameter.
      Parameters:
      code - the client code query parameter
      Returns:
      the client query
    • setKey

      public ClientQuery setKey(String key)
      Set the client key query parameter.
      Parameters:
      key - the client key query parameter
      Returns:
      the client query
    • setName

      public ClientQuery setName(String name)
      Set the client name query parameter.
      Parameters:
      name - the client name query parameter
      Returns:
      the client query
    • setFetchLimit

      public ClientQuery 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 client query
    • addOrderByAsc

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

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

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

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

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

      public Client firstValue()
      Execute the query and return the first client value object for the query.
      Returns:
      execute the query and return the first client value object for the query
    • firstJson

      public String firstJson()
      Execute the query and return the first client JSON value.
      Returns:
      execute the query and return the first client JSON value