List of usage examples for org.hibernate JDBCException getSQLException
public SQLException getSQLException()
From source file:org.transitime.db.structs.Block.java
License:Open Source License
/** * Uses lazy initialization to determine the trips for the block. * // ww w. jav a2s .c o m * @return the trips */ public List<Trip> getTrips() { // It appears that lazy initialization is problematic when have multiple // simultaneous threads. Get "org.hibernate.AssertionFailure: force // initialize loading collection". Therefore need to make sure that // only loading lazy sub-data serially. Since it is desirable to have // trips collection be lazy loaded so that app starts right away without // loading all the sub-data for every block assignment need to make // sure this is done in a serialized way. Having app not load all data // at startup is especially important when debugging. if (!Hibernate.isInitialized(trips)) { // trips not yet initialized so synchronize so only a single // thread can initialize at once and then access something // in trips that will cause it to be lazy loaded. synchronized (lazyLoadingSyncObject) { logger.debug("About to do lazy load for trips data for " + "blockId={} serviceId={}...", blockId, serviceId); IntervalTimer timer = new IntervalTimer(); // Access the collection so that it is lazy loaded. // Problems can be difficult to debug so log error along // with the SQL. try { trips.get(0); } catch (JDBCException e) { logger.error("In Block.getTrips() got JDBCException. " + "SQL=\"{}\" msg={}", e.getSQL(), e.getSQLException().getMessage()); throw e; } logger.debug("Finished lazy load for trips data for " + "blockId={} serviceId={}. Took {} msec", blockId, serviceId, timer.elapsedMsec()); } } return Collections.unmodifiableList(trips); }
From source file:org.vectorcorp.security.beans.RegisterBean.java
public String registerAccount() { String viewName;//w w w . j a v a 2s . c o m AccessControl ac = new AccessControl(); errorMsg = ""; ac.setUserName(userName); ac.setPassword(new byte[] { 0x01 }); ac.setStatus(AccessKeeper.STATUS_EXPIRED); ac.setValidTill(Calendar.getInstance().getTime()); try { AccessKeeper.createAccessControl(ac, selectedRoles); viewName = SUCCESS_PAGE; } catch (ConstraintViolationException cve) { if (AccessControl.PK_NAME.equals(cve.getConstraintName())) errorMsg = DUPLICATE_NAME; viewName = FAILURE_PAGE; } catch (JDBCException e) { errorMsg = e.getSQLException().getMessage(); viewName = FAILURE_PAGE; } return viewName; }
From source file:pl.umk.mat.zawodyweb.www.RequestBean.java
License:Open Source License
@HttpAction(name = "dellanguage", pattern = "del/{id}/language") public String deleteLanguage(@Param(name = "id", encode = true) int id) { if (rolesBean.canEditAnyProblem()) { try {//from w ww .jav a2 s.com languagesDAO.deleteById(id); HibernateUtil.getSessionFactory().getCurrentSession().getTransaction().commit(); HibernateUtil.getSessionFactory().getCurrentSession().beginTransaction(); } catch (JDBCException e) { e.printStackTrace(); SQLException ex = e.getSQLException(); while ((ex = ex.getNextException()) != null) { ex.printStackTrace(); } } return "/admin/listlanguages"; } else { return "/error/404"; } }
From source file:pl.umk.mat.zawodyweb.www.RequestBean.java
License:Open Source License
@HttpAction(name = "delseries", pattern = "del/{id}/series") public String deleteSeries(@Param(name = "id", encode = true) int id) { Series s = seriesDAO.getById(id);//from w ww. ja v a2s . c om if (s != null && rolesBean.canDeleteSeries(s.getContests().getId(), id)) { try { seriesDAO.delete(s); HibernateUtil.getSessionFactory().getCurrentSession().getTransaction().commit(); HibernateUtil.getSessionFactory().getCurrentSession().beginTransaction(); } catch (JDBCException e) { e.printStackTrace(); SQLException ex = e.getSQLException(); while ((ex = ex.getNextException()) != null) { ex.printStackTrace(); } } return "problems"; } else { return "/error/404"; } }
From source file:se.vgregion.service.innovationsslussen.idea.IdeaServiceImpl.java
License:Open Source License
void logAllErros(Exception e) { if (e instanceof JDBCException) { JDBCException jdbce = (JDBCException) e; e.printStackTrace();//from w w w . ja va 2 s .c o m jdbce.getSQLException().getNextException().printStackTrace(); } }