Search in sources :

Example 6 with HibernateException

use of org.hibernate.HibernateException in project head by mifos.

the class SystemInformationServiceFacadeWebTier method getServerInformation.

@Override
public String getServerInformation(ServletContext context, Locale locale) {
    try {
        DatabaseMetaData metaData = StaticHibernateUtil.getSessionTL().connection().getMetaData();
        final SystemInfo systemInfo = new SystemInfo(metaData, context, locale, true);
        return systemInfo.getApplicationServerInfo();
    } catch (HibernateException e) {
        throw new MifosRuntimeException(e);
    } catch (SQLException e) {
        throw new MifosRuntimeException(e);
    }
}
Also used : SystemInfo(org.mifos.application.admin.system.SystemInfo) HibernateException(org.hibernate.HibernateException) SQLException(java.sql.SQLException) DatabaseMetaData(java.sql.DatabaseMetaData) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 7 with HibernateException

use of org.hibernate.HibernateException in project head by mifos.

the class SystemInformationServiceFacadeWebTier method getSystemInformation.

@Override
public SystemInformationDto getSystemInformation(ServletContext context, Locale locale) {
    try {
        DatabaseMetaData metaData = StaticHibernateUtil.getSessionTL().connection().getMetaData();
        final SystemInfo systemInfo = new SystemInfo(metaData, context, locale, true);
        systemInfo.setCustomReportsDir(BirtReportsUploadAction.getCustomReportStorageDirectory());
        return new SystemInformationDto(systemInfo.getApplicationServerInfo(), systemInfo.getApplicationVersion(), systemInfo.getBuildDate(), systemInfo.getBuildNumber(), systemInfo.getCommitIdentifier(), systemInfo.getCustomReportsDir(), systemInfo.getDatabaseName(), systemInfo.getDatabasePort(), systemInfo.getDatabaseServer(), systemInfo.getDatabaseUser(), systemInfo.getDatabaseVendor(), systemInfo.getDatabaseVersion(), systemInfo.getDriverName(), systemInfo.getDriverVersion(), systemInfo.getDateTimeString(), systemInfo.getDateTimeStringIso8601(), systemInfo.getInfoSource(), systemInfo.getInfoURL(), systemInfo.getJavaVendor(), systemInfo.getJavaVersion(), systemInfo.getOsArch(), systemInfo.getOsName(), systemInfo.getOsUser(), systemInfo.getOsVersion(), systemInfo.getReleaseName());
    } catch (HibernateException e) {
        throw new MifosRuntimeException(e);
    } catch (SQLException e) {
        throw new MifosRuntimeException(e);
    }
}
Also used : SystemInfo(org.mifos.application.admin.system.SystemInfo) HibernateException(org.hibernate.HibernateException) SQLException(java.sql.SQLException) DatabaseMetaData(java.sql.DatabaseMetaData) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 8 with HibernateException

use of org.hibernate.HibernateException in project hibernate-orm by hibernate.

the class EnversIntegrator method integrate.

public void integrate(Metadata metadata, SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) {
    final EnversService enversService = serviceRegistry.getService(EnversService.class);
    // Opt-out of registration if EnversService is disabled
    if (!enversService.isEnabled()) {
        log.debug("Skipping Envers listener registrations : EnversService disabled");
        return;
    }
    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    // Opt-out of registration if asked to not register
    final boolean autoRegister = serviceRegistry.getService(ConfigurationService.class).getSetting(AUTO_REGISTER, StandardConverters.BOOLEAN, true);
    if (!autoRegister) {
        log.debug("Skipping Envers listener registrations : Listener auto-registration disabled");
        return;
    }
    // Verify that the EnversService is fully initialized and ready to go.
    if (!enversService.isInitialized()) {
        throw new HibernateException("Expecting EnversService to have been initialized prior to call to EnversIntegrator#integrate");
    }
    // Opt-out of registration if no audited entities found
    if (!enversService.getEntitiesConfigurations().hasAuditedEntities()) {
        log.debug("Skipping Envers listener registrations : No audited entities found");
        return;
    }
    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    // Do the registrations
    final EventListenerRegistry listenerRegistry = serviceRegistry.getService(EventListenerRegistry.class);
    listenerRegistry.addDuplicationStrategy(EnversListenerDuplicationStrategy.INSTANCE);
    if (enversService.getEntitiesConfigurations().hasAuditedEntities()) {
        listenerRegistry.appendListeners(EventType.POST_DELETE, new EnversPostDeleteEventListenerImpl(enversService));
        listenerRegistry.appendListeners(EventType.POST_INSERT, new EnversPostInsertEventListenerImpl(enversService));
        listenerRegistry.appendListeners(EventType.PRE_UPDATE, new EnversPreUpdateEventListenerImpl(enversService));
        listenerRegistry.appendListeners(EventType.POST_UPDATE, new EnversPostUpdateEventListenerImpl(enversService));
        listenerRegistry.appendListeners(EventType.POST_COLLECTION_RECREATE, new EnversPostCollectionRecreateEventListenerImpl(enversService));
        listenerRegistry.appendListeners(EventType.PRE_COLLECTION_REMOVE, new EnversPreCollectionRemoveEventListenerImpl(enversService));
        listenerRegistry.appendListeners(EventType.PRE_COLLECTION_UPDATE, new EnversPreCollectionUpdateEventListenerImpl(enversService));
    }
}
Also used : HibernateException(org.hibernate.HibernateException) EnversPreUpdateEventListenerImpl(org.hibernate.envers.event.spi.EnversPreUpdateEventListenerImpl) EnversPreCollectionRemoveEventListenerImpl(org.hibernate.envers.event.spi.EnversPreCollectionRemoveEventListenerImpl) EnversPreCollectionUpdateEventListenerImpl(org.hibernate.envers.event.spi.EnversPreCollectionUpdateEventListenerImpl) EnversPostInsertEventListenerImpl(org.hibernate.envers.event.spi.EnversPostInsertEventListenerImpl) ConfigurationService(org.hibernate.engine.config.spi.ConfigurationService) EnversPostUpdateEventListenerImpl(org.hibernate.envers.event.spi.EnversPostUpdateEventListenerImpl) EnversPostCollectionRecreateEventListenerImpl(org.hibernate.envers.event.spi.EnversPostCollectionRecreateEventListenerImpl) EnversPostDeleteEventListenerImpl(org.hibernate.envers.event.spi.EnversPostDeleteEventListenerImpl) EventListenerRegistry(org.hibernate.event.service.spi.EventListenerRegistry)

Example 9 with HibernateException

use of org.hibernate.HibernateException in project hibernate-orm by hibernate.

the class HikariCPConnectionProvider method configure.

// *************************************************************************
// Configurable
// *************************************************************************
@SuppressWarnings("rawtypes")
@Override
public void configure(Map props) throws HibernateException {
    try {
        LOGGER.debug("Configuring HikariCP");
        hcfg = HikariConfigurationUtil.loadConfiguration(props);
        hds = new HikariDataSource(hcfg);
    } catch (Exception e) {
        throw new HibernateException(e);
    }
    LOGGER.debug("HikariCP Configured");
}
Also used : HikariDataSource(com.zaxxer.hikari.HikariDataSource) HibernateException(org.hibernate.HibernateException) SQLException(java.sql.SQLException) UnknownUnwrapTypeException(org.hibernate.service.UnknownUnwrapTypeException) HibernateException(org.hibernate.HibernateException)

Example 10 with HibernateException

use of org.hibernate.HibernateException in project head by mifos.

the class BranchReportHelper method execute.

@Override
public void execute(long timeInMillis) throws BatchJobException {
    Session session = StaticHibernateUtil.getSessionTL();
    StaticHibernateUtil.startTransaction();
    Date runDate = new Date(timeInMillis);
    try {
        removeExistingBranchReportsForGivenRunDate(runDate);
        populateBranchReportBatch(session, runDate);
        StaticHibernateUtil.commitTransaction();
    } catch (HibernateException e) {
        StaticHibernateUtil.rollbackTransaction();
        throw new BatchJobException(e);
    } catch (ServiceException e) {
        throw new BatchJobException(e);
    }
}
Also used : BatchJobException(org.mifos.framework.components.batchjobs.exceptions.BatchJobException) ServiceException(org.mifos.framework.exceptions.ServiceException) HibernateException(org.hibernate.HibernateException) Date(java.util.Date) Session(org.hibernate.Session)

Aggregations

HibernateException (org.hibernate.HibernateException)609 Session (org.hibernate.Session)285 DAOException (com.tomasio.projects.trainning.exception.DAOException)186 DAOException (org.jbei.ice.storage.DAOException)122 ArrayList (java.util.ArrayList)63 Criteria (org.hibernate.Criteria)56 Test (org.junit.Test)43 Transaction (org.hibernate.Transaction)39 SQLException (java.sql.SQLException)38 SimpleDateFormat (java.text.SimpleDateFormat)22 Query (org.hibernate.Query)20 IOException (java.io.IOException)19 ParseException (java.text.ParseException)18 TestForIssue (org.hibernate.testing.TestForIssue)16 Date (java.util.Date)13 List (java.util.List)12 PersistenceException (org.mifos.framework.exceptions.PersistenceException)12 Serializable (java.io.Serializable)11 HashMap (java.util.HashMap)11 SessionFactoryImplementor (org.hibernate.engine.spi.SessionFactoryImplementor)11