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);
}
}
use of org.hibernate.HibernateException in project hibernate-orm by hibernate.
the class AdditionalJaxbMappingProducerImpl method produceAdditionalMappings.
@Override
public Collection<MappingDocument> produceAdditionalMappings(final MetadataImplementor metadata, IndexView jandexIndex, final MappingBinder mappingBinder, final MetadataBuildingContext buildingContext) {
final ServiceRegistry serviceRegistry = metadata.getMetadataBuildingOptions().getServiceRegistry();
final EnversService enversService = serviceRegistry.getService(EnversService.class);
if (!enversService.isEnabled()) {
// short-circuit if envers integration has been disabled.
return Collections.emptyList();
}
final ArrayList<MappingDocument> additionalMappingDocuments = new ArrayList<>();
// atm we do not have distinct origin info for envers
final Origin origin = new Origin(SourceType.OTHER, "envers");
// final DOMWriter writer = new DOMWriter();
final MappingCollector mappingCollector = new MappingCollector() {
@Override
public void addDocument(Document document) throws DocumentException {
dump(document);
// while the commented-out code here is more efficient (well, understanding that
// this whole process is un-efficient) it leads to un-decipherable messages when
// we get mapping mapping errors from envers output.
// final DOMSource domSource = new DOMSource( writer.write( document ) );
// domSource.setSystemId( "envers" );
// final Binding jaxbBinding = mappingBinder.bind( domSource, origin );
// this form at least allows us to get better error messages
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
final Writer w = new BufferedWriter(new OutputStreamWriter(baos, "UTF-8"));
final XMLWriter xw = new XMLWriter(w, new OutputFormat(" ", true));
xw.write(document);
w.flush();
} catch (IOException e) {
throw new HibernateException("Unable to bind Envers-generated XML", e);
}
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
BufferedInputStream bis = new BufferedInputStream(bais);
final Binding jaxbBinding = mappingBinder.bind(bis, origin);
final JaxbHbmHibernateMapping jaxbRoot = (JaxbHbmHibernateMapping) jaxbBinding.getRoot();
additionalMappingDocuments.add(new MappingDocument(jaxbRoot, origin, buildingContext));
}
};
enversService.initialize(metadata, mappingCollector);
return additionalMappingDocuments;
}
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));
}
}
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");
}
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);
}
}
Aggregations