use of jodd.db.DbSessionProvider in project jodd by oblac.
the class DefaultAppCore method startDb.
/**
* Initializes database. First, creates connection pool.
* and transaction manager. Then, Jodds DbOomManager is
* configured. It is also configured automagically, by scanning
* the class path for entities.
*/
@SuppressWarnings("unchecked")
protected void startDb() {
if (!useDatabase) {
log.info("database is not used");
return;
}
log.info("database initialization");
// connection pool
connectionProvider = createConnectionProvider();
petite.addBean(PETITE_DBPOOL, connectionProvider);
connectionProvider.init();
checkConnectionProvider();
// transactions manager
jtxManager = createJtxTransactionManager(connectionProvider);
jtxManager.setValidateExistingTransaction(true);
AnnotationTxAdviceManager annTxAdviceManager = new AnnotationTxAdviceManager(jtxManager, jtxScopePattern);
annTxAdviceManager.registerAnnotations(jtxAnnotations);
AnnotationTxAdviceSupport.manager = annTxAdviceManager;
DbSessionProvider sessionProvider = new DbJtxSessionProvider(jtxManager);
// global settings
DbManager dbManager = DbManager.getInstance();
dbManager.setConnectionProvider(connectionProvider);
dbManager.setSessionProvider(sessionProvider);
petite.addBean(PETITE_DB, dbManager);
DbOomManager dbOomManager = DbOomManager.getInstance();
petite.addBean(PETITE_DBOOM, dbOomManager);
// automatic configuration
registerDbEntities(dbOomManager);
}
Aggregations