| Constructor and Description | 
|---|
| DB() | 
| Modifier and Type | Method and Description | 
|---|---|
| Schema | addDynamicModelDefinition(DynamicModelDefinition def)Add a dynamicModelDefinition to the internal registry of schemas | 
| Schema | addModel(Class cls)Add a model to the internal registry of schemas. | 
| static boolean | available() | 
| protected String | buildCacheKey(Class model,
             String sql,
             Object... args)Turns a SQL query into a unique md5 hash to be used as a cache key. | 
| <T extends Model> | cachedQuery(Class<T> model,
           String sql,
           Object... args)Find a list of objects via arbitrary SQL, checking the cache first, and storing to the
 cache if retrieved fromt he database. | 
| <T> T | cachedScalar(Class model,
            String sql,
            Object... params)Find a single value based on the given model, from arbitrary SQL, and
 use the cache. | 
| <T extends Model> | cachedWhere(Class<T> model,
           String where,
           Object... args)Select from the given model, using just an arbitrary WHERE ... | 
| boolean | columnExists(String tableName,
            String column) | 
| Object | convertColumnArg(Model o,
                Col col,
                Object arg)Trys to convert java type into what is needed by JDBC to store to the database. | 
| void | delete(Model obj)Delete the object from the database. | 
| int | execute(String sql,
       Object... params)Execute an arbitrary SQL command, return the affected rows. | 
| <T extends Model> | fetchAll(Class<? extends T> model,
        String field,
        Object value)Fetch all objects where column field is of value | 
| <T extends Model> | fetchAll(Class<T> model)Fetch all objects of the given model. | 
| <T extends Model> | fetchAllSorted(Class<? extends T> model,
              String sortField,
              String sortDirection)Fetch all objects, sorted | 
| <T> T | fetchOne(Class<? extends T> model,
        Object id)Fetch the object with the given id. | 
| <T> T | fetchOne(Class<? extends T> model,
        String field,
        Object value)Fetch an object where field==value | 
| Map<String,Object> | findRecord(String sql,
          Object... args)Find one record via arbitrary SQL and return it as a hashmap | 
| List<Map<String,Object>> | findRecords(String sql,
           Object... args)Find a list of rows via arbitrary SQL, and return those rows as hashmaps | 
| AttributeConverter | getConverter(String className)Get or instantiate an AttributeConverter instance based on the
 converter className | 
| DataSource | getDataSource()Get the underlying database connection pool | 
| DbImplementation | getDbImplementation() | 
| Class | getDefaultPersisterClass() | 
| Schema | getSchema(Class cls)Get the table schema for a given model class | 
| Schema | getSchema(String name)Get the table schema for a model name | 
| List<Schema> | getSchemas() | 
| Tickets | getTickets()Get the Tickets service for generating new IDS | 
| void | initialize(DbConfig config)Intialize the database based on the passed in configuration object. | 
| Model | insert(Model obj)Insert the object into the database. | 
| static DB | instance() | 
| static boolean | isUseDummyPersisterForSqlGenerationMode()If true, internally, DalRegistry.register() will never use a DbPersister, instead
 it will use a DummyPersister. | 
| static DB | load()Load the database based on the configuration defined in the stallion.toml settings. | 
| Schema | modelToSchema(Class cls) | 
| org.apache.commons.dbutils.QueryRunner | newQuery()Returns a QueryRunner instance associated with the underlying dataSource | 
| Tickets | newTicketsGeneratorInstance()Instantiate an instance of a Tickets subclass, based on the database type | 
| <T extends Model> | query(Class<T> model,
     String sql,
     Object... args)Find a list of objects of the given model via arbitrary SQL | 
| <T> List<T> | queryBean(Class<T> model,
         String sql,
         Object... args)Find a list of objects of the given model via arbitrary SQL. | 
| <T extends Model> | queryForOne(Class<T> model,
           String sql,
           Object... args)Find one object of the given model via arbitrary SQL | 
| <T> T | queryScalar(String sql,
           Object... params)Query the database with arbitrary SQL and return a scalar object (a string, number, boolean, etc). | 
| DB | registerConverter(AttributeConverter converter) | 
| Model | save(Model obj)Update the database with this object, or insert it if it does not exist. | 
| void | setDataSource(DataSource dataSource) | 
| static void | setUseDummyPersisterForSqlGenerationMode(boolean useDummyPersisterForSqlGenerationMode) | 
| static void | shutdown()Close the datasource pool, null out the singleton instance. | 
| boolean | tableExists(String tableName) | 
| int | update(Model obj)Update the object | 
| int | update(Model obj,
      Map<String,Object> values)Update only the passed in key values | 
| Object | where(Class model,
     String where,
     Object... args)Find an object using an arbitrary SQL WHERE ... | 
public DB()
public static boolean available()
public static DB load()
public static void shutdown()
public void initialize(DbConfig config)
config - public Tickets newTicketsGeneratorInstance()
public Class getDefaultPersisterClass()
public DB registerConverter(AttributeConverter converter)
public org.apache.commons.dbutils.QueryRunner newQuery()
public Model save(Model obj)
obj - public <T> T queryScalar(String sql, Object... params)
T - sql - params - public <T extends Model> List<T> fetchAll(Class<T> model)
T - model - public <T> T fetchOne(Class<? extends T> model, Object id)
T - model - id - public <T> T fetchOne(Class<? extends T> model, String field, Object value)
T - model - field - value - public <T extends Model> List<T> fetchAll(Class<? extends T> model, String field, Object value)
T - model - field - value - public <T extends Model> List<T> fetchAllSorted(Class<? extends T> model, String sortField, String sortDirection)
T - model - public List<Map<String,Object>> findRecords(String sql, Object... args)
sql - args - public Map<String,Object> findRecord(String sql, Object... args)
sql - args - public <T extends Model> T queryForOne(Class<T> model, String sql, Object... args)
T - model - sql - args - public <T extends Model> List<T> query(Class<T> model, String sql, Object... args)
T - model - sql - args - public <T> List<T> queryBean(Class<T> model, String sql, Object... args)
T - model - sql - args - public <T extends Model> List<T> cachedQuery(Class<T> model, String sql, Object... args)
T - model - sql - args - public <T> T cachedScalar(Class model, String sql, Object... params)
T - model - sql - params - public <T extends Model> List<T> cachedWhere(Class<T> model, String where, Object... args)
T - model - where - args - protected String buildCacheKey(Class model, String sql, Object... args)
model - sql - args - public Object where(Class model, String where, Object... args)
model - where - args - public int update(Model obj, Map<String,Object> values)
obj - public Model insert(Model obj)
obj - public Object convertColumnArg(Model o, Col col, Object arg)
o - col - arg - public Schema addModel(Class cls)
cls - public Schema addDynamicModelDefinition(DynamicModelDefinition def)
def - public Schema modelToSchema(Class cls)
public List<Schema> getSchemas()
public int execute(String sql, Object... params)
sql - params - public AttributeConverter getConverter(String className)
className - public boolean tableExists(String tableName)
public boolean columnExists(String tableName, String column)
public Schema getSchema(Class cls)
cls - public Schema getSchema(String name)
name - public DataSource getDataSource()
public void setDataSource(DataSource dataSource)
public Tickets getTickets()
public DbImplementation getDbImplementation()
public static boolean isUseDummyPersisterForSqlGenerationMode()
public static void setUseDummyPersisterForSqlGenerationMode(boolean useDummyPersisterForSqlGenerationMode)
Copyright © 2016. All rights reserved.