Class BeanResult<T>

All Implemented Interfaces:
Serializable, Cloneable, Iterable<T>, Collection<T>, List<T>, RandomAccess

public class BeanResult<T> extends ArrayList<T>
BeanResult This is a simple helper class that performs reading a list of beans from a query Internally DBReader.getBeanList() is used.
Author:
doebele
See Also:
  • Constructor Details

    • BeanResult

      public BeanResult(Class<T> beanType, DBCommand cmd)
      Create a bean result from a command object. No checks will be performed here whether the command is compatible with the supplied class.
      Parameters:
      beanType - the bean type
      cmd - the command
    • BeanResult

      public BeanResult(Class<T> beanType, DBRowSet rowset)
      Creates a bean result for a Table, View or Query from the supplied columns. At least one column must match the given getters / setters on the supplied class otherwise an BeanIncompatibleException will be thrown.
      Parameters:
      beanType - the of T
      rowset - the rowset
  • Method Details

    • getCommand

      public DBCommand getCommand()
      Returns the current command Used to add constraints, order, grouping etc.
      Returns:
      the command
    • fetch

      public int fetch(DBContext context, int maxItems)
      Executes the query and fetches the result
      Parameters:
      context - the database context
      maxItems - the maximum number of items to query
      Returns:
      the number of items fetched by the query
    • fetch

      public final int fetch(DBContext context)
      Executes the query and fetches the result
      Parameters:
      context - the database context
      Returns:
      the number of items fetched by the query
    • autoSelectColumns

      protected void autoSelectColumns(DBRowSet rowset)
      Selects all columns for a given rowset
      Parameters:
      rowset - the rowset for which to select all columns
    • isPropertyAcessible

      protected boolean isPropertyAcessible(Method[] methods, String property, DataType dataType)
      Checks if the property is accessible i.e. has a getter method on the beanType
      Parameters:
      methods - the beanType methods
      property - the property to check
      dataType - the dataType
      Returns:
      true if the property is accessible or false otherwise