public class DaoManager extends Object
NOTE: To use this cache, you should make sure you've added a DatabaseTable.daoClass()
value to the
annotation to the top of your class.
Constructor and Description |
---|
DaoManager() |
Modifier and Type | Method and Description |
---|---|
static void |
addCachedDatabaseConfigs(Collection<DatabaseTableConfig<?>> configs)
This adds database table configurations to the internal cache which can be used to speed up DAO construction.
|
static void |
clearCache()
Clear out all of internal caches.
|
static void |
clearDaoCache()
Clear out our DAO caches.
|
static <D extends Dao<T,?>,T> |
createDao(ConnectionSource connectionSource,
Class<T> clazz)
Helper method to create a DAO object without having to define a class.
|
static <D extends Dao<T,?>,T> |
createDao(ConnectionSource connectionSource,
DatabaseTableConfig<T> tableConfig)
Helper method to create a DAO object without having to define a class.
|
static <D extends Dao<T,?>,T> |
lookupDao(ConnectionSource connectionSource,
Class<T> clazz)
Helper method to lookup a DAO if it has already been associated with the class.
|
static <D extends Dao<T,?>,T> |
lookupDao(ConnectionSource connectionSource,
DatabaseTableConfig<T> tableConfig)
Helper method to lookup a DAO if it has already been associated with the table-config.
|
static void |
registerDao(ConnectionSource connectionSource,
Dao<?,?> dao)
Register the DAO with the cache.
|
static void |
registerDaoWithTableConfig(ConnectionSource connectionSource,
Dao<?,?> dao)
Same as
registerDao(ConnectionSource, Dao) but this allows you to register it just with its
DatabaseTableConfig . |
static void |
unregisterDao(ConnectionSource connectionSource,
Dao<?,?> dao)
Remove a DAO from the cache.
|
static void |
unregisterDaos(ConnectionSource connectionSource)
Remove all DAOs from the cache for the connection source.
|
public static <D extends Dao<T,?>,T> D createDao(ConnectionSource connectionSource, Class<T> clazz) throws SQLException
BaseDaoImpl.createDao(ConnectionSource, Class)
.SQLException
public static <D extends Dao<T,?>,T> D lookupDao(ConnectionSource connectionSource, Class<T> clazz)
public static <D extends Dao<T,?>,T> D createDao(ConnectionSource connectionSource, DatabaseTableConfig<T> tableConfig) throws SQLException
BaseDaoImpl.createDao(ConnectionSource, DatabaseTableConfig)
.SQLException
public static <D extends Dao<T,?>,T> D lookupDao(ConnectionSource connectionSource, DatabaseTableConfig<T> tableConfig)
public static void registerDao(ConnectionSource connectionSource, Dao<?,?> dao)
NOTE: By default this registers the DAO to be associated with the class that it uses. If you need to
register multiple dao's that use different DatabaseTableConfig
s then you should use
registerDaoWithTableConfig(ConnectionSource, Dao)
.
NOTE: You should maybe use the DatabaseTable.daoClass()
and have the DaoManager construct the DAO
if possible.
public static void unregisterDao(ConnectionSource connectionSource, Dao<?,?> dao)
public static void unregisterDaos(ConnectionSource connectionSource)
public static void registerDaoWithTableConfig(ConnectionSource connectionSource, Dao<?,?> dao)
registerDao(ConnectionSource, Dao)
but this allows you to register it just with its
DatabaseTableConfig
. This allows multiple versions of the DAO to be configured if necessary.public static void clearCache()
public static void clearDaoCache()
public static void addCachedDatabaseConfigs(Collection<DatabaseTableConfig<?>> configs)
This documentation is licensed by Gray Watson under the Creative Commons Attribution-Share Alike 3.0 License.