Class RoleQuery


  • public class RoleQuery
    extends Object

    Provides a role query class.

    Examples

    Please find the Role query examples about list, get first and count below.

    Role Query List Example

    This Groovy example shows how to list roles matching certain criteria ordered ascending by name (maximum number of 4 records).

     import com.avoka.tm.query.*
     import com.avoka.tm.vo.*
    
     List<Role> roles = new RoleQuery()
         .setFetchLimit(4)
         .addOrderByAsc("name")
         .listValues()
    
     // In JSON format
     String rolesJson = new RoleQuery()
         .setFetchLimit(4)
         .addOrderByAsc("name")
         .listJson() 

    Role Query First Example

    This Groovy example shows how to get first role matching certain criteria ordered descending by id.

     import com.avoka.tm.query.*
     import com.avoka.tm.vo.*
    
     Role role = new RoleQuery()
         .setName(roleName)
         .firstValue()
    
     // In JSON format
     String roleJson = new RoleQuery()
         .setName(roleName)
         .firstJson()  
    Since:
    19.11.0
    See Also:
    Role
    • Constructor Detail

      • RoleQuery

        public RoleQuery()
    • Method Detail

      • setId

        public RoleQuery setId​(Long id)
        Set the role id (PK) query parameter.
        Parameters:
        id - the role id (PK) query parameter
        Returns:
        the role query
      • setName

        public RoleQuery setName​(String name)
        Set the role name query parameter.
        Parameters:
        name - the role name query parameter
        Returns:
        the role query
      • setFetchLimit

        public RoleQuery 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 role query
      • addOrderByAsc

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

        public RoleQuery addOrderByDesc​(String orderProperty)
        Add the sort order by descending to the query.
        Parameters:
        orderProperty - the property to sort by (required)
        Returns:
        the role 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<Role> listValues()
        Execute the role query and return a list of Role value objects.
        Returns:
        execute the role query and return a list of Role value objects
      • listJson

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

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

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