|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface ActiveRecordSupport<T>
If a entity class implements ActiveRecordSupport interface, it will have CRUD Method. This interface is designed for jSqlBox Java8 version because Java8 support default method interface is not useful for Java7 and below.
| Field Summary | |
|---|---|
static ThreadLocal<String[]> |
lastTimePutFieldsCache
|
| Method Summary | ||
|---|---|---|
SqlItem |
bind(Object... parameters)
For tXxxx style templateEngine use, return a SqlItemType.PUT type SqlItem instance, Usage: put("key1",value1,"key2",value2...); |
|
int |
countAll(Object... optionItems)
Return how many records for current entity class |
|
SqlBoxContext |
ctx(Object... optionItems)
|
|
void |
delete(Object... optionItems)
Delete entity in database, if not 1 row deleted, throw SqlBoxException |
|
void |
deleteById(Object id,
Object... optionItems)
Delete entity by given id, if not 1 row deleted, throw SqlBoxException |
|
int |
deleteByIdTry(Object id,
Object... optionItems)
Delete entity by given id, return how many rows deleted |
|
int |
deleteTry(Object... optionItems)
Delete entity in database, return how many rows affected |
|
boolean |
exist(Object... optionItems)
Check if entity exist by its id |
|
boolean |
existById(Object id,
Object... optionItems)
Check if entity exist by given id |
|
List<T> |
findAll(Object... optionItems)
Find all entity of same entity class, if not found, return empty list |
|
List<T> |
findByIds(Iterable<?> ids,
Object... optionItems)
Find all entity according its id, if not found, return empty list |
|
List<T> |
findBySample(Object sampleBean,
Object... optionItems)
Find entity according a sample bean, ignore null fields, if not found, return empty list |
|
List<T> |
findBySQL(Object... optionItems)
Find entity according SQL, if not found, return empty list |
|
|
findOneRelated(Object... sqlItems)
Find one related entity |
|
|
findRelatedList(Object... sqlItems)
Find related entity List |
|
|
findRelatedMap(Object... sqlItems)
Find related entity Map |
|
|
findRelatedSet(Object... sqlItems)
Find related entity Set |
|
|
guess(Object... params)
In SqlMapper style, based on current method @Sql annotated String or Text(see user manual) in comments(need put Java file in resources folder, see user manual) and parameters, guess a best fit query/update/delete/execute method and run it |
|
PreparedSQL |
guessPreparedSQL(Object... params)
In SqlMapper style, return current method's prepared SQL |
|
String |
guessSQL()
In SqlMapper style, return current method's SQL String based on current method @Sql annotated String or Text(see user manual) in comments(need put Java file in resources folder, see user manual) |
|
T |
insert(Object... optionItems)
Insert entity to database, if not 1 row updated, throw SqlBoxException |
|
T |
load(Object... optionItems)
Load entity according its id, if not 1 row round, throw SqlBoxException |
|
T |
loadById(Object id,
Object... optionItems)
Load entity by given id, if not 1 row found, throw SqlBoxException |
|
T |
loadByIdTry(Object id,
Object... optionItems)
Load entity by given id, if not found, return null |
|
int |
loadTry(Object... optionItems)
Load entity according its id, return how many rows found |
|
T |
put(Object... fieldAndValues)
Link style set values for entity field, format like: user.put("id","id1").put("name","Sam").put("address","Beijing","phone","12345", "email","abc@123.com") |
|
T |
putFields(String... fieldNames)
Cache a field array in ThreadLocal for putValues method use |
|
T |
putValues(Object... values)
Put values for entity fields, field names should be cached by call putFields method first |
|
SqlBoxContext |
shardDB(Object... optionItems)
Return current entity's shardDatabase according its sharding key values |
|
String |
shardTB(Object... optionItems)
Return current entity's shardTable according its sharding key values |
|
T |
update(Object... optionItems)
Update entity in database, if not 1 row updated, throw SqlBoxException |
|
int |
updateTry(Object... optionItems)
Update entity in database, return how many rows affected |
|
| Field Detail |
|---|
static final ThreadLocal<String[]> lastTimePutFieldsCache
| Method Detail |
|---|
SqlBoxContext ctx(Object... optionItems)
T insert(Object... optionItems)
T update(Object... optionItems)
int updateTry(Object... optionItems)
void delete(Object... optionItems)
int deleteTry(Object... optionItems)
void deleteById(Object id,
Object... optionItems)
int deleteByIdTry(Object id,
Object... optionItems)
boolean exist(Object... optionItems)
boolean existById(Object id,
Object... optionItems)
int countAll(Object... optionItems)
T load(Object... optionItems)
int loadTry(Object... optionItems)
T loadById(Object id,
Object... optionItems)
T loadByIdTry(Object id,
Object... optionItems)
List<T> findAll(Object... optionItems)
List<T> findByIds(Iterable<?> ids,
Object... optionItems)
List<T> findBySQL(Object... optionItems)
List<T> findBySample(Object sampleBean,
Object... optionItems)
<E> E findOneRelated(Object... sqlItems)
<E> List<E> findRelatedList(Object... sqlItems)
<E> Set<E> findRelatedSet(Object... sqlItems)
<E> Map<Object,E> findRelatedMap(Object... sqlItems)
T put(Object... fieldAndValues)
T putFields(String... fieldNames)
T putValues(Object... values)
<U> U guess(Object... params)
String guessSQL()
PreparedSQL guessPreparedSQL(Object... params)
SqlItem bind(Object... parameters)
String shardTB(Object... optionItems)
SqlBoxContext shardDB(Object... optionItems)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||