public interface BeanSession
| Modifier and Type | Method and Description |
|---|---|
void |
addTrigger(TriggerListener trigger)
Add a TriggerListener in this session.
|
QueryBuilder |
buildQuery()
Builds a new QueryBuilder so it's possible to create fluent custom SQL queries
|
String |
buildSelect(Class<? extends Object> beanClass) |
String |
buildSelect(Class<? extends Object> beanClass,
Object... properties) |
String |
buildSelect(Class<? extends Object> beanClass,
String tableName) |
String |
buildSelect(Class<? extends Object> beanClass,
String tableName,
Object... properties) |
String |
buildSelectMinus(Class<? extends Object> beanClass,
Object... minus) |
String |
buildSelectMinus(Class<? extends Object> beanClass,
String tableName,
Object... minus) |
String |
buildTableName(Class<? extends Object> clazz)
Returns the table name configured for the given class
|
<E> E |
compareDifferences(E bean,
E another,
List<String> nullProps)
Compare differences between two beans holding the properties of first bean passed and
adding null properties in nullProps list.
|
int |
countList(Object bean)
Count the number of beans that would be returned by a loadList method.
|
<E> E |
createBasicInstance(E bean)
Creates an single instance only with primary keys according the given object
|
void |
createTable(Class<? extends Object> beanKlass) |
<E> TableAlias<E> |
createTableAlias(Class<? extends E> beanClass)
Return a table alias for this bean class
|
<E> TableAlias<E> |
createTableAlias(Class<? extends E> beanClass,
String prefix)
Return a table alias for this bean class with a prefix.
|
void |
createTables() |
boolean |
delete(Object bean)
Delete the bean from the database.
|
int |
deleteAll(Object bean)
Delete all data based on the properties present in the bean passed
The PK doesn't need to be set
|
void |
dropTable(Class<? extends Object> beanKlass) |
BeanConfig |
getConfigFor(Class<?> clazz)
Returns the BeanConfig object from the given bean class
|
Connection |
getConnection()
Get the database connection being used by this bean session.
|
void |
insert(Object bean)
Insert the bean in the database.
|
boolean |
load(Object bean)
Load the bean from the database, injecting all its properties through reflection.
|
boolean |
load(Object bean,
Object... properties) |
<E> List<E> |
loadList(E bean)
Load a list of beans based on the properties present in the bean passed.
|
<E> List<E> |
loadList(E bean,
Limit limit)
Same as loadList(bean) except that you can limit the number of beans returned in the list.
|
<E> List<E> |
loadList(E bean,
Limit limit,
Object... properties) |
<E> List<E> |
loadList(E bean,
Object... properties) |
<E> List<E> |
loadList(E bean,
OrderBy orderBy)
Same as loadList(bean) except that you can order the list returned by passing an SQL orderBy clause.
|
<E> List<E> |
loadList(E bean,
OrderBy orderBy,
Limit limit)
Same as loadList(bean) except that you can limit the number of beans returned in the list as well as sort them by passing a orderBy SQL clause.
|
<E> List<E> |
loadList(E bean,
OrderBy orderBy,
Limit limit,
Object... properties) |
<E> List<E> |
loadList(E bean,
OrderBy orderBy,
Object... properties) |
<E> List<E> |
loadListMinus(E bean,
Limit limit,
Object... minus) |
<E> List<E> |
loadListMinus(E bean,
Object... minus) |
<E> List<E> |
loadListMinus(E bean,
OrderBy orderBy,
Limit limit,
Object... minus) |
<E> List<E> |
loadListMinus(E bean,
OrderBy orderBy,
Object... minus) |
boolean |
loadMinus(Object bean,
Object... minus) |
<E> E |
loadUnique(E bean)
Same as loadList(bean) but it attempts to load a single bean only.
|
<E> E |
loadUnique(E bean,
Object... properties) |
<E> E |
loadUniqueMinus(E bean,
Object... minus) |
void |
populateBean(ResultSet rset,
Object bean) |
void |
populateBean(ResultSet rset,
Object bean,
Object... properties) |
void |
populateBean(ResultSet rset,
Object bean,
String tableName) |
void |
populateBean(ResultSet rset,
Object bean,
String tableName,
Object... properties) |
void |
populateBeanMinus(ResultSet rset,
Object bean,
Object... minus) |
void |
populateBeanMinus(ResultSet rset,
Object bean,
String tableName,
Object... minus) |
String |
propertyToColumn(Class<? extends Object> clazz,
Object property) |
String |
propertyToColumn(Class<? extends Object> clazz,
Object property,
String alias) |
void |
removeTrigger(TriggerListener trigger)
Removes the TriggerListener from session
|
int |
save(Object bean,
Object... forceNull)
Tries to update or insert a bean using the
update method. |
int |
saveAll(Object bean)
Tries to update or insert a bean object into database.
|
int |
update(Object bean,
Object... forceNull)
Update the bean in the database.
|
int |
updateAll(Object bean)
Same as update(bean) but here you can turn off the default dynamic update behavior and force all bean properties to be updated regardless whether they have been modified or not.
|
<E> int |
updateDiff(E newBean,
E oldBean)
Updates an object using only the differences between newBean and oldBean instances.
|
static final int UPDATE
static final int INSERT
Connection getConnection()
boolean load(Object bean)
bean - The bean we want to load from the DB.int update(Object bean, Object... forceNull)
bean - The bean to be updatedforceNull - Database columns that will be forced to null if the bean property is not setint updateAll(Object bean)
bean - Exception<E> int updateDiff(E newBean,
E oldBean)
newBean - oldBean - void insert(Object bean)
bean - The bean to insertint save(Object bean, Object... forceNull)
update method.bean - The bean to update or insertforceNull - Database columns that will be forced to null (or zero) if the bean property is not setupdate and 1 (one) if insert method was executedsaveAll(Object),
update(Object, Object...)int saveAll(Object bean)
updateAll method.bean - The bean to update or insertupdate and 1 (one) if insert method was executedupdateAll(Object)boolean delete(Object bean)
bean - Exceptionint deleteAll(Object bean)
bean - int countList(Object bean)
bean - The bean holding the properties used by the list query.<E> List<E> loadList(E bean)
E - bean - The bean holding the properties used by the list query.<E> List<E> loadList(E bean, OrderBy orderBy)
E - bean - The bean holding the properties used by the list query.orderBy - The orderBy SQL clause.<E> List<E> loadList(E bean, Limit limit)
E - bean - The bean holding the properties used by the list query.limit - The max number of beans returned in the list.<E> List<E> loadList(E bean, OrderBy orderBy, Limit limit)
E - bean - The bean holding the properties used by the list query.orderBy - The orderBy SQL clause.limit - The max number of beans returned in the list.<E> E loadUnique(E bean)
E - bean - The bean holding the properties used by the load query.BeanException - if more than one bean is found by the query.<E> E loadUnique(E bean,
Object... properties)
<E> E loadUniqueMinus(E bean,
Object... minus)
String buildSelect(Class<? extends Object> beanClass, String tableName, Object... properties)
String buildSelectMinus(Class<? extends Object> beanClass, String tableName, Object... minus)
void populateBeanMinus(ResultSet rset, Object bean, String tableName, Object... minus)
void createTables()
String propertyToColumn(Class<? extends Object> clazz, Object property, String alias)
<E> E createBasicInstance(E bean)
bean - - The bean with all primary key set<E> E compareDifferences(E bean,
E another,
List<String> nullProps)
bean - another - nullProps - An empty listString buildTableName(Class<? extends Object> clazz)
clazz - - The bean classBeanConfig getConfigFor(Class<?> clazz)
clazz - QueryBuilder buildQuery()
void addTrigger(TriggerListener trigger)
trigger - void removeTrigger(TriggerListener trigger)
trigger - <E> TableAlias<E> createTableAlias(Class<? extends E> beanClass)
beanClass - <E> TableAlias<E> createTableAlias(Class<? extends E> beanClass, String prefix)
beanClass - prefix - Copyright © 2016. All Rights Reserved.