public interface Queryable
Queryable
is bound with the SQL executed, so some Queryable
re-executing must be evicted, like:
Queryable myQuery = QueryFactory.of("my-query"); Number number = repository.scalar(myQuery); List list = repository.list(myQuery); // wrong myQuery as marked with scalar result
Modifier and Type | Method and Description |
---|---|
void |
bind(Sql sql)
Bind Sql to
Queryable instance generating the raw query. |
<T,R> AutoBindParams |
bind(StatementAdapter<T,R> adapter) |
void |
cached()
mark the query result as cache
|
void |
cacheIgnore()
Specifies intentionally to no retrieve the data from cache, the query must be hit the database
|
String |
getBookmark()
Get a record of which page selected to mark the reader's place
|
Sql |
getDynamicSql()
Dynamic SQL statement from XML file.
|
<T> Filter<T> |
getFilter()
A filter function, to keep the result which imposes a total ordering on some collection of objects
|
int |
getMax()
Get the maximum number of rows from query result.
|
String |
getName()
The query name used to localize the query at in XML file.
|
int |
getOffset()
Get the number from first row from query result.
|
<T> T |
getParams()
Parameters of query.
|
String[] |
getParamsNames()
Name of parameters that bound with final SQL statement
|
Param |
getProperty(String name)
Recover the value of the named parameter (can be nested), with no type conversions.
|
Param |
getProperty(String name,
int index) |
RegisterType |
getRegisterType() |
<T> Class<T> |
getReturnType()
Overload the return type from XML query.
|
<T> Comparator<T> |
getSorter()
A comparison function, which imposes a total ordering on some collection of objects
|
long |
getTotal()
Get total of rows that query can retrieve, filled after query is
executed.
|
boolean |
hasFilter()
Has an filter to include/exclude rows from result.
|
boolean |
hasReturnType()
Default value of
getReturnType() is java.util.Map instance,
this method check if there is a type is not default. |
boolean |
hasRowsOffset()
Is there a offset to skip first rows?
|
boolean |
hasSorter()
Has an ordering imposed by a comparator.
|
boolean |
isBoundParams()
Check if the parameters from queryable was bind to
StatementAdapter instance. |
boolean |
isBoundSql()
Check if SQL object was bind to this instance.
|
boolean |
isCached()
Indicate the query result is from cache, isn't from repository.
|
boolean |
isCacheIgnore()
Verify was marked to ignore the cache.
|
boolean |
isPaging()
Is there a max row limit indicated?
|
boolean |
isScalar()
verify if the query is scalar value.
|
boolean |
isTypeOfArray()
verify if the parameter is an array
|
boolean |
isTypeOfArrayBasicTypes() |
boolean |
isTypeOfArrayMap() |
boolean |
isTypeOfArrayPojo() |
boolean |
isTypeOfBasic() |
boolean |
isTypeOfBulk()
verify if the parameter is a collection or array
|
boolean |
isTypeOfCollection()
verify if the parameter is a collection
|
boolean |
isTypeOfCollectionArray() |
boolean |
isTypeOfCollectionBasicTypes() |
boolean |
isTypeOfCollectionMap() |
boolean |
isTypeOfCollectionPojo() |
boolean |
isTypeOfMap()
verify if the parameter is a map
|
boolean |
isTypeOfNull() |
boolean |
isTypeOfPojo()
verify if the parameter is a pojo
|
Iterator<Param> |
iterator()
Returns an iterator over the collection of
params or array of params . |
String |
query()
Final SQL statement ready to prepared statement.
|
String |
queryCount()
Final SQL statement ready to prepared statement to count the total of records from original query.
|
void |
scalar()
Mark the query as scalar value, means must be return just one value
|
void |
setBookmark(String bookmark)
Define a page selected to mark the reader's place
|
void |
setMax(int value)
Set the maximum number of rows from query result.
|
void |
setOffset(int value)
Set the number from first row from query result.
|
void |
setTotal(long total)
Set total of rows if run non paging query.
|
Param[] |
values()
Extract the values from
params matching the names array. |
String getName()
<T> T getParams()
T
- generic type to returnParam getProperty(String name)
name
- indexed and/or nested name of the property to be recoveredParameterNotFoundException
- when cannot find the property.Param getProperty(String name, int index)
int getOffset()
void setOffset(int value)
value
- initial value of row numberint getMax()
void setMax(int value)
value
- max row number to be fetchlong getTotal()
n
- the real rows total-1
- the query isn't executed yet-2
- the query was executed successfully but the number of rows is unavailable,
for example, result from cache always return this-3
- the query was executed with error and the number of rows is unavailablevoid setTotal(long total)
total
- of records running full selectboolean isPaging()
boolean hasRowsOffset()
void scalar()
boolean isScalar()
true
when the retrieve unique value, false
otherwiseboolean isBoundSql()
true
when was bind, false
otherwise.boolean isBoundParams()
StatementAdapter
instance.true
when was bind, false
otherwise.boolean isTypeOfNull()
boolean isTypeOfBasic()
boolean isTypeOfArrayBasicTypes()
boolean isTypeOfCollectionBasicTypes()
boolean isTypeOfArrayPojo()
boolean isTypeOfArrayMap()
boolean isTypeOfCollectionMap()
boolean isTypeOfCollectionPojo()
boolean isTypeOfCollectionArray()
boolean isTypeOfArray()
true
when they are, false
otherwiseboolean isTypeOfCollection()
true
when they are, false
otherwiseboolean isTypeOfBulk()
true
when they are, false
otherwiseboolean isTypeOfMap()
true
when they are, false
otherwiseboolean isTypeOfPojo()
true
when is, false
otherwiseIterator<Param> iterator()
params
or array of params
.
There are no guarantees concerning the order in which the elements are returnedparams
UnsupportedOperationException
- when params
isn't collection or array.NullPointerException
- when params
is null
.Param[] values()
params
matching the names array.array
of values from params
, base-zero array is returned when
the names doesn't match.ParameterException
- when a parameter values not correspond the type expectedvoid bind(Sql sql)
Queryable
instance generating the raw query.sql
- The instance of static or dynamic SQL statementIllegalStateException
- when o sql
is tried to be reassigned<T,R> AutoBindParams bind(StatementAdapter<T,R> adapter)
Sql getDynamicSql()
String query()
Note: Needs to bind bind(Sql)
before to call this method.
String queryCount()
Note: Needs to bind bind(Sql)
before to call this method.
String[] getParamsNames()
<T> Class<T> getReturnType()
T
- type of return classboolean hasReturnType()
getReturnType()
is java.util.Map
instance,
this method check if there is a type is not default.true
if there is a return type, false
otherwisevoid cacheIgnore()
boolean isCacheIgnore()
true
when cache ignore was invoked, false
otherwise.boolean isCached()
true
when the result fetch from cache, false
when fetch from repositoryvoid cached()
String getBookmark()
void setBookmark(String bookmark)
bookmark
- A string that enables you to specify which page of results you requireRegisterType getRegisterType()
<T> Comparator<T> getSorter()
T
- type to be comparable<T> Filter<T> getFilter()
T
- the type of the items to be filteredboolean hasSorter()
true
when the results must be sorted, false
otherwise.boolean hasFilter()
true
when the results must be filtered, false
otherwise.Copyright © 2012–2020 jkniv, copyleft code. All rights reserved.