List of usage examples for org.hibernate JDBCException getSQLException
public SQLException getSQLException()
From source file:co.nubetech.crux.dao.ReportDAO.java
License:Apache License
public long saveReport(Report report) throws CruxException { try {/*from w w w .j av a2 s .c o m*/ transaction.begin(); session.saveOrUpdate(report); transaction.commit(); } catch (JDBCException e) { transaction.rollback(); throw new CruxException(e.getSQLException().getMessage(), e); } return report.getId(); }
From source file:co.nubetech.crux.dao.ReportDesignDAO.java
License:Apache License
public long save(ReportDesign report) throws CruxException { try {//from w w w .j a v a2 s . c o m transaction.begin(); session.saveOrUpdate(report); transaction.commit(); } catch (JDBCException e) { transaction.rollback(); throw new CruxException(e.getSQLException().getMessage(), e); } return report.getId(); }
From source file:co.nubetech.crux.dao.ReportDesignDAO.java
License:Apache License
public long delete(ReportDesign report) throws CruxException { long id = report.getId(); try {//from w ww .ja v a 2s. c o m transaction.begin(); session.delete(report); transaction.commit(); } catch (JDBCException e) { transaction.rollback(); throw new CruxException(e.getSQLException().getMessage(), e); } return id; }
From source file:co.nubetech.crux.dao.RowAliasDAO.java
License:Apache License
public long save(RowAlias rowAlias) throws CruxException { try {//from ww w . j av a 2 s .co m transaction.begin(); session.saveOrUpdate(rowAlias); transaction.commit(); } catch (JDBCException e) { transaction.rollback(); throw new CruxException(e.getSQLException().getMessage(), e); } return rowAlias.getId(); }
From source file:co.nubetech.crux.dao.RowAliasDAO.java
License:Apache License
public long delete(RowAlias rowAlias) throws CruxException { long id = rowAlias.getId(); try {//w w w. j ava 2s . c om transaction.begin(); session.delete(rowAlias); transaction.commit(); } catch (JDBCException e) { transaction.rollback(); throw new CruxException(e.getSQLException().getMessage(), e); } return id; }
From source file:co.nubetech.crux.dao.RowFilterDAO.java
License:Apache License
public long save(RowAliasFilter rowFilter) throws CruxException { try {/*from w w w . j a v a 2 s .com*/ transaction.begin(); session.saveOrUpdate(rowFilter); transaction.commit(); } catch (JDBCException e) { transaction.rollback(); throw new CruxException(e.getSQLException().getMessage(), e); } return rowFilter.getId(); }
From source file:co.nubetech.crux.dao.RowFilterDAO.java
License:Apache License
public long delete(RowAliasFilter rowFilter) throws CruxException { long id = rowFilter.getId(); try {/*from w w w. j a v a 2s .co m*/ transaction.begin(); session.delete(rowFilter); transaction.commit(); } catch (JDBCException e) { transaction.rollback(); throw new CruxException(e.getSQLException().getMessage(), e); } return id; }
From source file:com.gu.management.database.checking.ConnectionCheckResultClassifier.java
License:Apache License
private boolean containsSevereErrorMessage(JDBCException jdbcFailureCause) { for (String severeErrorMessage : severeErrorMessages) { if (jdbcFailureCause.getSQLException().getMessage().contains(severeErrorMessage)) { return true; }/* w w w . j a va 2s . c o m*/ } return false; }
From source file:com.mg.framework.service.PersistentManagerHibernateImpl.java
License:Open Source License
public void flush() { Session s = getCurrentSession();// w ww. j a v a 2 s .c om try { s.flush(); } catch (JDBCException e) { s.clear(); throw SQLExceptionTranslatorManagerLocator.locate().translate(e.getSQLException()); } catch (CallbackException e) { throw convertCallbackExceptionToDatabaseException(e); } catch (Exception e) { try { ServerUtils.getCurrentTransaction().setRollbackOnly(); } catch (Exception ee) { //we do not want the subsequent exception to swallow the original one log.error("Unable to mark for rollback on Exception: ", ee); } if (e instanceof ApplicationException) throw (ApplicationException) e; else throw new DataAccessException(e); } }
From source file:com.opensymphony.able.filter.SimpleTransactionServletFilter.java
License:Apache License
public void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain filterChain) throws IOException, ServletException { // TODO we could get clever and figure out what URIs are read only transactions etc final TransactionTemplate transactionTemplate = (TransactionTemplate) context .getBean("transactionTemplate"); transactionTemplate.setReadOnly(false); if (log.isDebugEnabled()) { log.debug("Starting a transaction"); }//ww w. j a v a 2s. c om try { Exception e = (Exception) transactionTemplate.execute(new TransactionCallback() { public Object doInTransaction(TransactionStatus status) { try { TransactionOutcome outcome = new TransactionOutcome(status, transactionTemplate); TransactionOutcome.setTransactionOutcome(outcome); filterChain.doFilter(request, response); if (outcome.isRollbackOnly()) { log.debug("Outcome is rollback"); status.setRollbackOnly(); } if (log.isDebugEnabled()) { log.debug("Completing a transaction with rollback: " + status.isRollbackOnly()); } return null; } catch (RuntimeException e) { throw e; } catch (Exception e) { return e; } } }); if (log.isDebugEnabled()) { log.debug("End transaction with exception: " + e); } if (e instanceof IOException) { throw (IOException) e; } else if (e instanceof ServletException) { throw (ServletException) e; } else if (e != null) { throw new ServletException(e); } } catch (TransactionException e) { Throwable cause = e.getCause(); if (cause.getCause() != null) { cause = cause.getCause(); } ; if (cause instanceof JDBCException) { JDBCException jdbcException = (JDBCException) cause; SQLException sqlException = jdbcException.getSQLException(); throw new ServletException("Failed to execute: " + jdbcException.getSQL() + ": error: " + sqlException.getSQLState() + ". Reason: " + sqlException, sqlException); } throw new ServletException(cause); } finally { TransactionOutcome.setTransactionOutcome(null); } }