use of com.manydesigns.portofino.persistence.hibernate.SessionFactoryBuilder in project Portofino by ManyDesigns.
the class Persistence method initConnectionProvider.
protected void initConnectionProvider(Database database) {
logger.info("Initializing connection provider for database " + database.getDatabaseName());
try {
ConnectionProvider connectionProvider = database.getConnectionProvider();
connectionProvider.init(databasePlatformsRegistry);
if (connectionProvider.getStatus().equals(ConnectionProvider.STATUS_CONNECTED)) {
MultiTenancyImplementation implementation = getMultiTenancyImplementation(database);
SessionFactoryBuilder builder = new SessionFactoryBuilder(database, configuration.getProperties(), implementation);
SessionFactoryAndCodeBase sessionFactoryAndCodeBase = builder.buildSessionFactory();
HibernateDatabaseSetup setup = new HibernateDatabaseSetup(database, sessionFactoryAndCodeBase.sessionFactory, sessionFactoryAndCodeBase.codeBase, builder.getEntityMode(), configuration.getProperties(), implementation);
String databaseName = database.getDatabaseName();
HibernateDatabaseSetup oldSetup = setups.get(databaseName);
setups.put(databaseName, setup);
if (oldSetup != null) {
oldSetup.dispose();
databaseSetupEvents.onNext(new DatabaseSetupEvent(oldSetup, setup));
} else {
databaseSetupEvents.onNext(new DatabaseSetupEvent(DatabaseSetupEvent.ADDED, setup));
}
}
} catch (Exception e) {
logger.error("Could not create connection provider for " + database, e);
}
}
Aggregations