use of org.hibernate.HibernateException in project hibernate-orm by hibernate.
the class ClassLoaderServiceImplTest method testStoppableClassLoaderService.
/**
* HHH-8363 discovered multiple leaks within CLS. Most notably, it wasn't getting GC'd due to holding
* references to ServiceLoaders. Ensure that the addition of Stoppable functionality cleans up properly.
*
* TODO: Is there a way to test that the ServiceLoader was actually reset?
*/
@Test
@TestForIssue(jiraKey = "HHH-8363")
public void testStoppableClassLoaderService() {
final BootstrapServiceRegistryBuilder bootstrapBuilder = new BootstrapServiceRegistryBuilder();
bootstrapBuilder.applyClassLoader(new TestClassLoader());
final ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder(bootstrapBuilder.build()).build();
final ClassLoaderService classLoaderService = serviceRegistry.getService(ClassLoaderService.class);
TestIntegrator testIntegrator1 = findTestIntegrator(classLoaderService);
assertNotNull(testIntegrator1);
TestIntegrator testIntegrator2 = findTestIntegrator(classLoaderService);
assertNotNull(testIntegrator2);
assertSame(testIntegrator1, testIntegrator2);
StandardServiceRegistryBuilder.destroy(serviceRegistry);
try {
findTestIntegrator(classLoaderService);
Assert.fail("Should have thrown an HibernateException -- the ClassLoaderService instance was closed.");
} catch (HibernateException e) {
String message = e.getMessage();
Assert.assertEquals("HHH000469: The ClassLoaderService can not be reused. This instance was stopped already.", message);
}
}
use of org.hibernate.HibernateException in project head by mifos.
the class LegacyAccountDao method updateLedgerAccount.
public void updateLedgerAccount(COABO coaBo, String accountName, String glCode, String parentGlCode) throws PersistenceException {
Session session = StaticHibernateUtil.getSessionTL();
Transaction transaction = session.beginTransaction();
try {
Short newParentId = getAccountIdFromGlCode(parentGlCode);
coaBo.setAccountName(accountName);
GLCodeEntity glCodeEntity = coaBo.getAssociatedGlcode();
createOrUpdate(coaBo);
glCodeEntity.setGlcode(glCode);
createOrUpdate(glCodeEntity);
Query query = session.getNamedQuery(NamedQueryConstants.SET_COA_PARENT);
query.setShort("parentId", newParentId);
query.setShort("id", coaBo.getAccountId());
query.executeUpdate();
transaction.commit();
} catch (HibernateException ex) {
transaction.rollback();
throw new PersistenceException(ex);
}
}
use of org.hibernate.HibernateException in project head by mifos.
the class LegacyAccountDao method getCountForGlCode.
public int getCountForGlCode(Short glCodeId) throws PersistenceException {
Session session = StaticHibernateUtil.getSessionTL();
int count = -1;
try {
Query query = session.getNamedQuery(NamedQueryConstants.COUNT_GL_CODE_REFERENCES);
query.setShort("glCodeId", glCodeId);
count = (Integer) query.uniqueResult();
} catch (HibernateException ex) {
throw new PersistenceException(ex);
}
return count;
}
use of org.hibernate.HibernateException in project head by mifos.
the class LegacyRolesPermissionsDao method getUserRoles.
/**
* This function returns the PersonRoles object which contains the person
* information and the set of all the roles related to that user
*
* @param uid
* user id
* @return PersonRoles
* @throws HibernateProcessException
*/
public Set getUserRoles(short uid) throws SystemException, ApplicationException {
Set roles = null;
try {
Session session = StaticHibernateUtil.getSessionTL();
Query personRoles = session.getNamedQuery(NamedQueryConstants.GETPERSONROLES);
personRoles.setShort("ID", uid);
List<PersonRoles> lst = personRoles.list();
if (null != lst && lst.size() > 0) {
PersonRoles pr = lst.get(0);
roles = pr.getRoles();
}
} catch (HibernateException he) {
throw new SecurityException(SecurityConstants.GENERALERROR, he);
}
return roles;
}
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);
}
}
Aggregations