|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.commons.dbutils.AbstractQueryRunner
org.apache.commons.dbutils.QueryRunner
com.github.drinkjava2.jdbpro.ImprovedQueryRunner
com.github.drinkjava2.jdbpro.DbPro
com.github.drinkjava2.jsqlbox.SqlBoxContext
public class SqlBoxContext
SqlBoxContext is extended from DbPro, DbPro is extended from QueryRunner, by
this way SqlBoxContext have all JDBC methods of QueryRunner and DbPro.
As a ORM tool, SqlBoxContext focus on ORM methods like entity bean's CRUD
methods and EntityNet methods.
| Field Summary | |
|---|---|
protected Dialect |
dialect
Dialect of current SqlBoxContext, optional |
protected static SqlBoxContext |
globalSqlBoxContext
|
static String |
NO_GLOBAL_SQLBOXCONTEXT_FOUND
|
protected ShardingTool[] |
shardingTools
|
protected SnowflakeCreator |
snowflakeCreator
|
protected SqlMapperGuesser |
sqlMapperGuesser
In SqlMapper style, A guesser needed to guess and execute SQL methods |
| Fields inherited from class com.github.drinkjava2.jdbpro.ImprovedQueryRunner |
|---|
allowShowSQL, batchSize, connectionManager, iocTool, logger, masters, masterSlaveOption, name, slaves, sqlHandlers, sqlTemplateEngine |
| Fields inherited from class org.apache.commons.dbutils.AbstractQueryRunner |
|---|
ds |
| Constructor Summary | |
|---|---|
SqlBoxContext()
|
|
SqlBoxContext(DataSource ds)
|
|
SqlBoxContext(DataSource ds,
SqlBoxContextConfig config)
|
|
SqlBoxContext(SqlBoxContextConfig config)
|
|
| Method Summary | ||
|---|---|---|
static
|
createMapper(Class<?> abstractClass)
Create a subClass instance of a abstract ActiveRecordSupport class based on default global SqlBoxContext |
|
protected boolean |
dealOneSqlItem(boolean iXxxStyle,
PreparedSQL ps,
Object item)
Override DbPro's dealItem method to deal SqlBoxContext's SqlItem |
|
protected void |
dialectShortcutMethods__________________________()
|
|
EntityNet |
entityAutoNet(Class<?>... entityClass)
Build a entityNet, only give both between start class and end classes |
|
int |
entityCountAll(Class<?> entityClass,
Object... optionItems)
Return how many records for current entity class |
|
protected void |
entityCrudMethods______________________________()
|
|
void |
entityDelete(Object entity,
Object... optionItems)
Delete entity in database, if not 1 row deleted, throw SqlBoxException |
|
void |
entityDeleteById(Class<?> entityClass,
Object id,
Object... optionItems)
Delete entity by given id, if not 1 row deleted, throw SqlBoxException |
|
int |
entityDeleteByIdTry(Class<?> entityClass,
Object id,
Object... optionItems)
Delete entity by given id, return how many rows deleted |
|
int |
entityDeleteTry(Object entity,
Object... optionItems)
Delete entity in database, return how many rows affected |
|
boolean |
entityExist(Object entity,
Object... optionItems)
Check if entity exist by its id |
|
boolean |
entityExistById(Class<?> entityClass,
Object id,
Object... optionItems)
Check if entity exist by given id |
|
|
entityFindAll(Class<T> entityClass,
Object... optionItems)
Find all entity of given entity class, if not found, return empty list |
|
|
entityFindByIds(Class<T> entityClass,
Iterable<?> ids,
Object... optionItems)
Find all entity according its id, if not found, return empty list |
|
|
entityFindBySample(Object sampleBean,
Object... optionItems)
Find entity according a sample bean, ignore null fields, if not found, return empty list |
|
|
entityFindBySQL(Object... optionItems)
Find entity according SQL, if not found, return empty list |
|
|
entityFindRelatedList(Object entityOrIterable,
Object... sqlItems)
Find related entity list by given entity or Iterable |
|
|
entityFindRelatedMap(Object entity,
Object... sqlItems)
Find related entity map(key is entityID) by given entity or Iterable |
|
|
entityFindRelatedOne(Object entity,
Object... sqlItems)
Find one related entity by given entity |
|
|
entityFindRelatedSet(Object entity,
Object... sqlItems)
Find related entity set by given entity or Iterable |
|
|
entityInsert(T entity,
Object... optionItems)
Insert entity to database, if not 1 row updated, throw SqlBoxException |
|
|
entityLoad(T entity,
Object... optionItems)
Load entity according its id, if not 1 row round, throw SqlBoxException |
|
|
entityLoadById(Class<T> entityClass,
Object entityId,
Object... optionItems)
Load entity by given id, if not 1 row found, throw SqlBoxException |
|
|
entityLoadByIdTry(Class<T> entityClass,
Object entityId,
Object... optionItems)
Load entity by given id, if not found, return null |
|
int |
entityLoadTry(Object entity,
Object... optionItems)
Load entity according its id, return how many rows found |
|
|
entityUpdate(Object entity,
Object... optionItems)
Update entity in database, if not 1 row updated, throw SqlBoxException |
|
int |
entityUpdateTry(Object entity,
Object... optionItems)
Update entity in database, return how many rows affected |
|
static SqlBoxContext |
gctx()
Shortcut method equal to getGlobalSqlBoxContext() |
|
Dialect |
getDialect()
|
|
static SqlBoxContext |
getGlobalSqlBoxContext()
Get the global static SqlBoxContext instance |
|
SqlBoxContext |
getShardedDB(Object entityOrClass,
Object... shardvalues)
Get the sharded DB(=SqlBoxContext) instance by given shard values |
|
String |
getShardedTB(Object entityOrClass,
Object... shardvalues)
Get the sharded table name by given shard values |
|
ShardingTool[] |
getShardingTools()
|
|
SnowflakeCreator |
getSnowflakeCreator()
|
|
SqlMapperGuesser |
getSqlMapperGuesser()
|
|
protected void |
getteSetters__________________________()
|
|
protected DbPro |
handleShardDatabase(PreparedSQL predSQL,
SqlItem item)
|
|
protected String |
handleShardTable(PreparedSQL predSQL,
SqlItem item)
|
|
|
iQueryForEntityList(Object... optionItems)
Use i style to query for an entity list |
|
protected void |
miscMethods______________________________()
|
|
String |
pagin(int pageNumber,
int pageSize,
String sql)
Shortcut call to dialect.pagin method |
|
String |
paginAndTrans(int pageNumber,
int pageSize,
String sql)
Shortcut call to dialect.paginAndTrans method |
|
|
pQueryForEntityList(Object... optionItems)
Use p style to query for an entity list |
|
static void |
resetGlobalVariants()
Reset all global SqlBox variants to default values |
|
void |
setDialect(Dialect dialect)
Deprecated. |
|
static void |
setGlobalSqlBoxContext(SqlBoxContext globalSqlBoxContext)
|
|
void |
setShardingTools(ShardingTool[] shardingTools)
Deprecated. |
|
void |
setSnowflakeCreator(SnowflakeCreator snowflakeCreator)
Deprecated. |
|
void |
setSqlMapperGuesser(SqlMapperGuesser sqlMapperGuesser)
Deprecated. |
|
String[] |
toCreateDDL(Class<?>... entityClasses)
Shortcut call to dialect.toCreateDDL method |
|
String[] |
toCreateDDL(TableModel... tables)
Shortcut call to dialect.toCreateDDL method |
|
String[] |
toDropAndCreateDDL(Class<?>... entityClasses)
Shortcut call to dialect.toDropAndCreateDDL method |
|
String[] |
toDropAndCreateDDL(TableModel... tables)
Shortcut call to dialect.toDropAndCreateDDL method |
|
String[] |
toDropDDL(Class<?>... entityClasses)
Shortcut call to dialect.toDropDDL method |
|
String[] |
toDropDDL(TableModel... tables)
Shortcut call to dialect.toDropDDL method |
|
|
tQueryForEntityList(Object... optionItems)
Use t style to query for an entity list |
|
String |
trans(String sql)
Shortcut call to dialect.trans method |
|
| Methods inherited from class org.apache.commons.dbutils.QueryRunner |
|---|
batch, batch, execute, execute, execute, execute, insert, insert, insert, insert, insertBatch, insertBatch, query, query, query, query, query, query, query, query, update, update, update, update, update, update |
| Methods inherited from class org.apache.commons.dbutils.AbstractQueryRunner |
|---|
close, close, fillStatementWithBean, fillStatementWithBean, getDataSource, isPmdKnownBroken, prepareStatement, rethrow, wrap |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String NO_GLOBAL_SQLBOXCONTEXT_FOUND
protected static SqlBoxContext globalSqlBoxContext
protected Dialect dialect
protected SqlMapperGuesser sqlMapperGuesser
protected ShardingTool[] shardingTools
protected SnowflakeCreator snowflakeCreator
| Constructor Detail |
|---|
public SqlBoxContext()
public SqlBoxContext(DataSource ds)
public SqlBoxContext(SqlBoxContextConfig config)
public SqlBoxContext(DataSource ds,
SqlBoxContextConfig config)
| Method Detail |
|---|
protected void miscMethods______________________________()
public static void resetGlobalVariants()
public static SqlBoxContext gctx()
public static SqlBoxContext getGlobalSqlBoxContext()
protected boolean dealOneSqlItem(boolean iXxxStyle,
PreparedSQL ps,
Object item)
dealOneSqlItem in class DbPropublic static <T> T createMapper(Class<?> abstractClass)
public String getShardedTB(Object entityOrClass,
Object... shardvalues)
public SqlBoxContext getShardedDB(Object entityOrClass,
Object... shardvalues)
protected String handleShardTable(PreparedSQL predSQL,
SqlItem item)
protected DbPro handleShardDatabase(PreparedSQL predSQL,
SqlItem item)
public <T> List<T> iQueryForEntityList(Object... optionItems)
public <T> List<T> pQueryForEntityList(Object... optionItems)
public <T> List<T> tQueryForEntityList(Object... optionItems)
protected void entityCrudMethods______________________________()
public <T> T entityInsert(T entity,
Object... optionItems)
public <T> T entityUpdate(Object entity,
Object... optionItems)
public int entityUpdateTry(Object entity,
Object... optionItems)
public void entityDelete(Object entity,
Object... optionItems)
public int entityDeleteTry(Object entity,
Object... optionItems)
public void entityDeleteById(Class<?> entityClass,
Object id,
Object... optionItems)
public int entityDeleteByIdTry(Class<?> entityClass,
Object id,
Object... optionItems)
public boolean entityExist(Object entity,
Object... optionItems)
public boolean entityExistById(Class<?> entityClass,
Object id,
Object... optionItems)
public int entityCountAll(Class<?> entityClass,
Object... optionItems)
public <T> T entityLoad(T entity,
Object... optionItems)
public int entityLoadTry(Object entity,
Object... optionItems)
public <T> T entityLoadById(Class<T> entityClass,
Object entityId,
Object... optionItems)
public <T> T entityLoadByIdTry(Class<T> entityClass,
Object entityId,
Object... optionItems)
public <T> List<T> entityFindAll(Class<T> entityClass,
Object... optionItems)
public <T> List<T> entityFindByIds(Class<T> entityClass,
Iterable<?> ids,
Object... optionItems)
public <T> List<T> entityFindBySQL(Object... optionItems)
public <T> List<T> entityFindBySample(Object sampleBean,
Object... optionItems)
public EntityNet entityAutoNet(Class<?>... entityClass)
public <E> E entityFindRelatedOne(Object entity,
Object... sqlItems)
public <E> List<E> entityFindRelatedList(Object entityOrIterable,
Object... sqlItems)
public <E> Set<E> entityFindRelatedSet(Object entity,
Object... sqlItems)
public <E> Map<Object,E> entityFindRelatedMap(Object entity,
Object... sqlItems)
protected void dialectShortcutMethods__________________________()
public String pagin(int pageNumber,
int pageSize,
String sql)
public String trans(String sql)
public String paginAndTrans(int pageNumber,
int pageSize,
String sql)
public String[] toCreateDDL(Class<?>... entityClasses)
public String[] toDropDDL(Class<?>... entityClasses)
public String[] toDropAndCreateDDL(Class<?>... entityClasses)
public String[] toCreateDDL(TableModel... tables)
public String[] toDropDDL(TableModel... tables)
public String[] toDropAndCreateDDL(TableModel... tables)
protected void getteSetters__________________________()
public Dialect getDialect()
@Deprecated public void setDialect(Dialect dialect)
public SqlMapperGuesser getSqlMapperGuesser()
@Deprecated public void setSqlMapperGuesser(SqlMapperGuesser sqlMapperGuesser)
public ShardingTool[] getShardingTools()
@Deprecated public void setShardingTools(ShardingTool[] shardingTools)
public SnowflakeCreator getSnowflakeCreator()
@Deprecated public void setSnowflakeCreator(SnowflakeCreator snowflakeCreator)
public static void setGlobalSqlBoxContext(SqlBoxContext globalSqlBoxContext)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||