Search in sources :

Example 1 with HibernateConfiguration

use of org.apereo.portal.hibernate.DelegatingHibernateIntegrator.HibernateConfiguration in project uPortal by Jasig.

the class DbTestImpl method printDbInfo.

@Override
public void printDbInfo() {
    boolean fail = false;
    logger.info("JDBC DataSources");
    for (final Entry<String, JdbcOperations> jdbcEntry : this.jdbcOperations.entrySet()) {
        final String jdbcName = jdbcEntry.getKey();
        try {
            logger.info("\t" + jdbcName);
            final JdbcOperations jdbcOps = jdbcEntry.getValue();
            jdbcOps.execute(new ConnectionCallback<Object>() {

                @Override
                public Object doInConnection(Connection con) throws SQLException, DataAccessException {
                    printInfo(con);
                    return null;
                }
            });
        } catch (Exception e) {
            logger.error("\t" + jdbcName + ": parse info", e);
            fail = true;
        }
        logger.info("");
    }
    logger.info("Hibernate Dialects");
    for (final Entry<String, HibernateConfiguration> configEntry : this.hibernateConfigurations.entrySet()) {
        final String persistenceUnit = configEntry.getKey();
        try {
            final HibernateConfiguration hibernateConfiguration = configEntry.getValue();
            final SessionFactoryImplementor sessionFactory = hibernateConfiguration.getSessionFactory();
            final Dialect dialect = sessionFactory.getDialect();
            logger.info("\t" + persistenceUnit + ": " + dialect);
        } catch (Exception e) {
            logger.error("\t" + persistenceUnit + ": Failed to resolve Dialect", e);
            fail = true;
        }
        logger.info("");
    }
    if (fail) {
        throw new RuntimeException("One or more of the portal data sources is not configured correctly or the target database is not available.");
    }
}
Also used : SQLException(java.sql.SQLException) SessionFactoryImplementor(org.hibernate.engine.spi.SessionFactoryImplementor) Connection(java.sql.Connection) JdbcOperations(org.springframework.jdbc.core.JdbcOperations) DataAccessException(org.springframework.dao.DataAccessException) SQLException(java.sql.SQLException) Dialect(org.hibernate.dialect.Dialect) HibernateConfiguration(org.apereo.portal.hibernate.DelegatingHibernateIntegrator.HibernateConfiguration) DataAccessException(org.springframework.dao.DataAccessException)

Aggregations

Connection (java.sql.Connection)1 SQLException (java.sql.SQLException)1 HibernateConfiguration (org.apereo.portal.hibernate.DelegatingHibernateIntegrator.HibernateConfiguration)1 Dialect (org.hibernate.dialect.Dialect)1 SessionFactoryImplementor (org.hibernate.engine.spi.SessionFactoryImplementor)1 DataAccessException (org.springframework.dao.DataAccessException)1 JdbcOperations (org.springframework.jdbc.core.JdbcOperations)1