Package org.apache.empire.data.bean
Class BeanResult<T>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<E>
java.util.ArrayList<T>
org.apache.empire.data.bean.BeanResult<T>
- All Implemented Interfaces:
Serializable,Cloneable,Iterable<T>,Collection<T>,List<T>,RandomAccess
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:
-
Field Summary
Fields inherited from class java.util.AbstractList
modCount -
Constructor Summary
ConstructorsConstructorDescriptionBeanResult(Class<T> beanType, DBCommand cmd) Create a bean result from a command object.BeanResult(Class<T> beanType, DBRowSet rowset) Creates a bean result for a Table, View or Query from the supplied columns. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidautoSelectColumns(DBRowSet rowset) Selects all columns for a given rowsetfinal intExecutes the query and fetches the resultintExecutes the query and fetches the resultReturns the current command Used to add constraints, order, grouping etc.protected booleanisPropertyAcessible(Method[] methods, String property, DataType dataType) Checks if the property is accessible i.e. has a getter method on the beanTypeMethods inherited from class java.util.ArrayList
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, equals, forEach, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeIf, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSizeMethods inherited from class java.util.AbstractCollection
containsAll, toStringMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, stream, toArrayMethods inherited from interface java.util.List
containsAll
-
Constructor Details
-
BeanResult
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 typecmd- the command
-
BeanResult
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 Trowset- the rowset
-
-
Method Details
-
getCommand
Returns the current command Used to add constraints, order, grouping etc.- Returns:
- the command
-
fetch
Executes the query and fetches the result- Parameters:
context- the database contextmaxItems- the maximum number of items to query- Returns:
- the number of items fetched by the query
-
fetch
Executes the query and fetches the result- Parameters:
context- the database context- Returns:
- the number of items fetched by the query
-
autoSelectColumns
Selects all columns for a given rowset- Parameters:
rowset- the rowset for which to select all columns
-
isPropertyAcessible
Checks if the property is accessible i.e. has a getter method on the beanType- Parameters:
methods- the beanType methodsproperty- the property to checkdataType- the dataType- Returns:
- true if the property is accessible or false otherwise
-