List of usage examples for org.hibernate HibernateException HibernateException
public HibernateException(Throwable cause)
From source file:com.example.app.model.resource.ResourceTypeUserType.java
License:Open Source License
@Override public boolean equals(Object x, Object y) throws HibernateException { if (Objects.equals(x, y)) return true; if ((x == null) || (y == null)) return false; ResourceType resourceType1 = (ResourceType) x; ResourceType resourceType2 = (ResourceType) y; final ResourceTypeService.Context context = new ResourceTypeService.Context( _siteContext.getOperationalSite()); String factory1 = _resourceTypeService.getFactoryIdentifier(context, resourceType1); if (factory1 == null) throw new HibernateException("Invalid ResourceType: " + x); String factory2 = _resourceTypeService.getFactoryIdentifier(context, resourceType2); if (factory2 == null) throw new HibernateException("Invalid ResourceType: " + y); return factory1.equals(factory2) && resourceType1.getIdentifier().equals(resourceType2.getIdentifier()); }
From source file:com.example.app.model.resource.ResourceTypeUserType.java
License:Open Source License
@Override public int hashCode(Object x) throws HibernateException { if (x == null) return 0; ResourceType resourceType = (ResourceType) x; String factory = _resourceTypeService.getFactoryIdentifier( new ResourceTypeService.Context(_siteContext.getOperationalSite()), resourceType); if (factory == null) throw new HibernateException("Invalid ResourceType: " + x); int res = factory.hashCode(); res = res * 37 + resourceType.getIdentifier().hashCode(); return res;/* ww w . ja v a2s . c o m*/ }
From source file:com.example.app.model.resource.ResourceTypeUserType.java
License:Open Source License
@Override public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session) throws HibernateException, SQLException { if (value == null) { // StringType.INSTANCE.nullSafeSet(st, null, index++, session); StringType.INSTANCE.nullSafeSet(st, null, index, session); } else {/*from www . j a v a2 s. c om*/ ResourceType resourceType = (ResourceType) value; String factory = _resourceTypeService.getFactoryIdentifier( new ResourceTypeService.Context(_siteContext.getOperationalSite()), resourceType); if (factory == null) { throw new HibernateException("Invalid ResourceType: " + value); } // StringType.INSTANCE.nullSafeSet(st, factory, index++, session); StringType.INSTANCE.nullSafeSet(st, resourceType.getIdentifier(), index, session); } }
From source file:com.example.app.model.resource.ResourceTypeUserType.java
License:Open Source License
@Override @Nullable/*from www .ja va2 s .com*/ public Serializable disassemble(Object value) throws HibernateException { if (value == null) return null; ResourceType resourceType = (ResourceType) value; String factory = _resourceTypeService.getFactoryIdentifier( new ResourceTypeService.Context(_siteContext.getOperationalSite()), resourceType); if (factory == null) { throw new HibernateException("Invalid ResourceType: " + value); } return new String[] { factory, resourceType.getIdentifier() }; }
From source file:com.example.app.profile.model.resource.ResourceTypeUserType.java
License:Open Source License
@Override public boolean equals(Object x, Object y) throws HibernateException { if (Objects.equals(x, y)) return true; if ((x == null) || (y == null)) return false; ResourceType resourceType1 = (ResourceType) x; ResourceType resourceType2 = (ResourceType) y; final ResourceTypeService.Context context = new ResourceTypeService.Context( _siteContext.getOperationalSite()); String factory1 = _resourceTypeService.getFactoryIdentifier(context, resourceType1); if (factory1 == null) throw new HibernateException("Invalid ResourceType: " + x); String factory2 = _resourceTypeService.getFactoryIdentifier(context, resourceType2); if (factory2 == null) throw new HibernateException("Invalid ResourceType: " + y); return Objects.equals(factory1, factory2) && Objects.equals(resourceType1.getIdentifier(), resourceType2.getIdentifier()); }
From source file:com.exilant.eGov.src.domain.ChartOfAccts.java
License:Open Source License
@Transactional public void insert(final Connection connection) throws SQLException, TaskFailedException { created = new SimpleDateFormat("dd/mm/yyyy").format(new Date()); try {/*from ww w. ja va 2s.co m*/ created = formatter.format(sdf.parse(created)); masterDataCache.removeFromCache("egi-activeCoaCodes"); masterDataCache.removeFromCache("egi-coaCodes"); masterDataCache.removeFromCache("egi-chartOfAccounts"); masterDataCache.removeFromCache("egi-coaPurposeId10"); masterDataCache.removeFromCache("egi-accountCodes"); masterDataCache.removeFromCache("egi-liabilityCOACodes"); masterDataCache.removeFromCache("egi-coaCodesForLiability"); setLastModified(created); setId(String.valueOf(PrimaryKeyGenerator.getNextKey("ChartOfAccounts"))); final String insertQuery = "INSERT INTO ChartOfAccounts (id, glCode, name, description, isActiveForPosting, " + " parentId, lastModified, modifiedBy, " + "created, purposeid,functionreqd, operation,type,classification,class,budgetCheckReq,majorcode)" + "values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; if (LOGGER.isDebugEnabled()) LOGGER.debug(insertQuery); persistenceService.getSession().createSQLQuery(insertQuery).setInteger(0, Integer.parseInt(id)) .setString(1, removeSingleQuotes(glCode)).setString(2, removeSingleQuotes(name)) .setString(3, removeSingleQuotes(description)) .setString(4, removeSingleQuotes(isActiveForPosting)).setString(5, removeSingleQuotes(parentId)) .setString(6, removeSingleQuotes(lastModified)).setString(7, removeSingleQuotes(modifiedBy)) .setString(8, removeSingleQuotes(created)).setString(9, removeSingleQuotes(purposeid)) .setString(10, removeSingleQuotes(functionreqd)).setString(11, removeSingleQuotes(operation)) .setString(12, removeSingleQuotes(type)).setString(13, removeSingleQuotes(classification)) .setString(14, removeSingleQuotes(classname)).setString(15, removeSingleQuotes(budgetCheckReqd)) .setString(16, removeSingleQuotes(getMajorCode(glCode))).executeUpdate(); } catch (final HibernateException e) { LOGGER.error("Exception occured while getting the data " + e.getMessage(), new HibernateException(e.getMessage())); } catch (final Exception e) { LOGGER.error("Exception occured while getting the data " + e.getMessage(), new Exception(e.getMessage())); } }
From source file:com.exilant.eGov.src.domain.ChartOfAccts.java
License:Open Source License
public void newUpdate() throws TaskFailedException, SQLException { created = eGovernCommon.getCurrentDate(); Query pstmt = null;/*w w w . j a va2 s . c o m*/ try { created = formatter.format(sdf.parse(created)); } catch (final ParseException parseExp) { if (LOGGER.isDebugEnabled()) LOGGER.debug(parseExp.getMessage(), parseExp); } setCreated(created); setLastModified(created); final StringBuilder query = new StringBuilder(500); query.append("update ChartOfAccounts set "); if (glCode != null) query.append("glCode=?,"); if (name != null) query.append("name=?,"); if (description != null) query.append("description=?,"); if (isActiveForPosting != null) query.append("ISACTIVEFORPOSTING=?,"); if (parentId != null) query.append("PARENTID=?,"); if (lastModified != null) query.append("LASTMODIFIED=?,"); if (modifiedBy != null) query.append("MODIFIEDBY=?,"); if (created != null) query.append("CREATED=?,"); if (purposeid != null) query.append("PURPOSEID=?,"); if (operation != null) query.append("OPERATION=?,"); if (FIEoperation != null) query.append("FIEOPERATION=?,"); if (type != null) query.append("type=?,"); if (classname != null) query.append("class=?,"); if (classification != null) query.append("CLASSIFICATION=?,"); if (functionreqd != null) query.append("FUNCTIONREQD=?,"); if (scheduleId != null) query.append("SCHEDULEID=?,"); if (FIEscheduleId != null) query.append("FIEscheduleId=?,"); if (receiptscheduleid != null) query.append("RECEIPTSCHEDULEID=?,"); if (receiptoperation != null) query.append("RECEIPTOPERATION=?,"); if (paymentscheduleid != null) query.append("PAYMENTSCHEDULEID=?,"); if (paymentoperation != null) query.append("PAYMENTOPERATION=?,"); if (budgetCheckReqd != null) query.append("BUDGETCHECKREQ=?,"); final int lastIndexOfComma = query.lastIndexOf(","); query.deleteCharAt(lastIndexOfComma); query.append(" where id=?"); try { int i = 1; pstmt = persistenceService.getSession().createSQLQuery(query.toString()); if (glCode != null) pstmt.setString(i++, glCode); if (name != null) pstmt.setString(i++, name); if (description != null) pstmt.setString(i++, description); if (isActiveForPosting != null) pstmt.setString(i++, isActiveForPosting); if (parentId != null) pstmt.setString(i++, parentId); if (lastModified != null) pstmt.setString(i++, lastModified); if (modifiedBy != null) pstmt.setString(i++, modifiedBy); if (created != null) pstmt.setString(i++, created); if (purposeid != null) pstmt.setString(i++, purposeid); if (operation != null) pstmt.setString(i++, operation); if (FIEoperation != null) pstmt.setString(i++, FIEoperation); if (type != null) pstmt.setString(i++, type); if (classname != null) pstmt.setString(i++, classname); if (classification != null) pstmt.setString(i++, classification); if (functionreqd != null) pstmt.setString(i++, functionreqd); if (scheduleId != null) pstmt.setString(i++, scheduleId); if (FIEscheduleId != null) pstmt.setInteger(i++, FIEscheduleId); if (receiptscheduleid != null) pstmt.setString(i++, receiptscheduleid); if (receiptoperation != null) pstmt.setString(i++, receiptoperation); if (paymentscheduleid != null) pstmt.setString(i++, paymentscheduleid); if (paymentoperation != null) pstmt.setString(i++, paymentoperation); if (budgetCheckReqd != null) pstmt.setString(i++, budgetCheckReqd); pstmt.setString(i++, id); pstmt.executeUpdate(); } catch (final HibernateException e) { LOGGER.error("Exception occured while getting the data " + e.getMessage(), new HibernateException(e.getMessage())); } catch (final Exception e) { LOGGER.error("Exception occured while getting the data " + e.getMessage(), new Exception(e.getMessage())); } }
From source file:com.exilant.GLEngine.ChartOfAccounts.java
License:Open Source License
public boolean isClosedForPosting(final String date) throws TaskFailedException { boolean isClosed = true; String chkqry = null;//from w ww . j a v a 2 s . c om Query psmt = null; Query psmt1 = null; try { final SimpleDateFormat formatter = new SimpleDateFormat("dd-MMM-yyyy"); CFinancialYear financialYearByDate = financialYearDAO.getFinancialYearByDate(formatter.parse(date)); if (financialYearByDate != null) isClosed = false; if (!isClosed) { List<Object[]> rs = null; final String qry = "SELECT id FROM closedPeriods WHERE to_char(startingDate, 'DD-MON-YYYY')<='" + date + "' AND endingDate>='" + date + "'"; if (LOGGER.isDebugEnabled()) LOGGER.debug(qry); psmt1 = persistenceService.getSession().createSQLQuery(qry); rs = psmt1.list(); if (!(rs != null && rs.size() > 0)) isClosed = false; else isClosed = true; } } catch (final HibernateException e) { isClosed = true; LOGGER.error("Exception occured while getting the data " + e.getMessage(), new HibernateException(e.getMessage())); } catch (final Exception e) { isClosed = true; LOGGER.error("Exception occured while getting the data " + e.getMessage(), new Exception(e.getMessage())); } return isClosed; }
From source file:com.fiveamsolutions.nci.commons.audit.AuditLogInterceptor.java
License:Open Source License
/** * {@inheritDoc}/* w ww . j a v a 2 s . c o m*/ */ @Override public void onCollectionUpdate(Object collection, Serializable key) { if (!(collection instanceof PersistentCollection) || !isEnabled()) { return; } PersistentCollection pc = (PersistentCollection) collection; Object owner = pc.getOwner(); if (!processor.isAuditableEntity(owner)) { return; } if (audits.get() == null) { audits.set(new HashSet<AuditLogHelper>()); } String role = pc.getRole(); Serializable oldSerial = pc.getStoredSnapshot(); Object oldValue = null; if (oldSerial != null && pc instanceof PersistentSet) { // PersistentSet seems to build a strange map where the key is also the value. oldValue = ((Map) oldSerial).keySet(); } else { oldValue = oldSerial; } Object newValue = pc.getValue(); int idx = role.lastIndexOf('.'); String className = role.substring(0, idx); String property = role.substring(idx + 1); if (collectionNeedsAuditing(owner, newValue, oldValue, property)) { Map<String, String> tabColMA = getColumnTableName(className, property); AuditLogRecord record = getOrCreateRecord(owner, key, className, tabColMA.get(TABLE_NAME), AuditType.UPDATE); Getter getter; try { //Use current thread's class loader, instead of this class's class loader. This //ensures accessibility to class BO even if nci-commons is created via a higher level class loader //than the application's class loader (web/ear class loader). getter = getIdGetter(Thread.currentThread().getContextClassLoader().loadClass(className)); } catch (ClassNotFoundException ex) { throw new HibernateException(ex); } AuditLogHelper helper = new AuditLogHelper(record, owner, getter); audits.get().add(helper); helper.getDetails().add(new DetailHelper(property, tabColMA.get(COLUMN_NAME), oldValue, newValue)); } }
From source file:com.fiveamsolutions.nci.commons.audit.DummyCompositeUserType.java
License:Open Source License
public Object getPropertyValue(Object component, int property) throws HibernateException { DummyCompositeField var = (DummyCompositeField) component; switch (property) { case 0://w w w.j a v a 2 s . c o m return var.getField1(); case 1: return var.getField2(); case 2: return var.getField3(); default: throw new HibernateException("Property " + property + " is invalid"); } }