public HibernateOptimisticLockingFailureException(StaleObjectStateException ex) { super(ex.getEntityName(), ex.getIdentifier(), ex); }
public HibernateOptimisticLockingFailureException(StaleObjectStateException ex) { super(ex.getEntityName(), ex.getIdentifier(), ex); }
protected PersistenceException wrapStaleStateException(StaleStateException e) { PersistenceException pe; if ( e instanceof StaleObjectStateException ) { final StaleObjectStateException sose = (StaleObjectStateException) e; final Serializable identifier = sose.getIdentifier(); if ( identifier != null ) { try { final Object entity = sharedSessionContract.internalLoad( sose.getEntityName(), identifier, false, true); if ( entity instanceof Serializable ) { //avoid some user errors regarding boundary crossing pe = new OptimisticLockException( e.getMessage(), e, entity ); } else { pe = new OptimisticLockException( e.getMessage(), e ); } } catch (EntityNotFoundException enfe) { pe = new OptimisticLockException( e.getMessage(), e ); } } else { pe = new OptimisticLockException( e.getMessage(), e ); } } else { pe = new OptimisticLockException( e.getMessage(), e ); } return pe; }
return new ObjectOptimisticLockingFailureException(hibEx.getEntityName(), hibEx.getIdentifier(), ex);
return new ObjectOptimisticLockingFailureException(hibEx.getEntityName(), hibEx.getIdentifier(), ex);
public HibernateOptimisticLockingFailureException(StaleObjectStateException ex) { super(ex.getEntityName(), ex.getIdentifier(), ex); }
public HibernateOptimisticLockingFailureException(StaleObjectStateException ex) { super(ex.getEntityName(), ex.getIdentifier(), ex); }
public HibernateOptimisticLockingFailureException(StaleObjectStateException ex) { super(ex.getEntityName(), ex.getIdentifier(), ex); }
/** * The constructor. * * @param cause is the {@link StaleObjectStateException}. */ public OptimisticLockingExceptionHibernate(StaleObjectStateException cause) { super(cause, getEntityRepresentation(cause.getEntityName()), cause.getIdentifier()); }
public ServiceException convert(Throwable t, String detail, Map<String, Object> extendedData) { String error = null; Map<String, Object> ex = null; if (t.getClass().equals(NonUniqueObjectException.class)) error = ENTITY_EXISTS; else if (t.getClass().equals(ObjectNotFoundException.class)) error = ENTITY_NOT_FOUND; else if (t.getClass().equals(NonUniqueResultException.class)) error = NON_UNIQUE_RESULT; else if (t.getClass().equals(StaleStateException.class) || t.getClass().equals(StaleObjectStateException.class) || t.getClass().equals(HibernateOptimisticLockException.class)) { error = OPTIMISTIC_LOCK; if (t instanceof HibernateOptimisticLockException) { ex = new HashMap<String, Object>(); ex.put("entity", ((HibernateOptimisticLockException)t).getEntity()); } else if (t instanceof StaleObjectStateException) { ex = new HashMap<String, Object>(); ex.put("entityName", ((StaleObjectStateException)t).getEntityName()); ex.put("identifier", ((StaleObjectStateException)t).getIdentifier()); } } else error = OTHER; ServiceException se = new ServiceException(error, t.getMessage(), detail, t); if (ex != null && !ex.isEmpty()) se.getExtendedData().putAll(ex); return se; }
private static net.sf.hibernate.StaleObjectStateException adaptStaleObjectStateException( final org.hibernate.StaleStateException ex) { org.hibernate.StaleObjectStateException stex = ex instanceof org.hibernate.StaleObjectStateException ? (org.hibernate.StaleObjectStateException) ex : null; final String message = ex.getMessage(); final String entityName = stex != null ? stex.getEntityName() : null; final Serializable identifier = stex != null ? stex.getIdentifier() : null; return new net.sf.hibernate.StaleObjectStateException(null, identifier) { @Override public String getMessage() { return message; } @Override public Class getPersistentClass() { try { return entityName != null ? Class.forName(entityName) : Object.class; } catch (ClassNotFoundException ex) { return Object.class; } } @Override public String toString() { return toStringWithClassName(this, net.sf.hibernate.StaleObjectStateException.class); } }; }
public static void rethrowOptimisticLockException(Session session, StaleObjectStateException sose) { Serializable identifier = sose.getIdentifier(); if (identifier != null) { try { Object entity = session.load(sose.getEntityName(), identifier); if (entity instanceof Serializable) { //avoid some user errors regarding boundary crossing throw new HibernateOptimisticLockException(null, sose, entity); } } catch (ObjectNotFoundException onfe) { // Ignored, StaleStateException will be rethrown } } } }
public PersistenceException wrapStaleStateException(StaleStateException e) { PersistenceException pe; if ( e instanceof StaleObjectStateException ) { StaleObjectStateException sose = (StaleObjectStateException) e; Serializable identifier = sose.getIdentifier(); if (identifier != null) { Object entity = getRawSession().load( sose.getEntityName(), identifier ); if ( entity instanceof Serializable ) { //avoid some user errors regarding boundary crossing pe = new OptimisticLockException( null, e, entity ); } else { pe = new OptimisticLockException( e ); } } else { pe = new OptimisticLockException( e ); } } else { pe = new OptimisticLockException( e ); } return pe; } }
if ( identifier != null ) { try { Object entity = getRawSession().load( sose.getEntityName(), identifier ); if ( entity instanceof Serializable ) {
protected PersistenceException wrapStaleStateException(StaleStateException e) { PersistenceException pe; if ( e instanceof StaleObjectStateException ) { final StaleObjectStateException sose = (StaleObjectStateException) e; final Object identifier = sose.getIdentifier(); if ( identifier != null ) { try { final Object entity = sharedSessionContract.internalLoad( sose.getEntityName(), identifier, false, true); if ( entity instanceof Serializable ) { //avoid some user errors regarding boundary crossing pe = new OptimisticLockException( e.getMessage(), e, entity ); } else { pe = new OptimisticLockException( e.getMessage(), e ); } } catch (EntityNotFoundException enfe) { pe = new OptimisticLockException( e.getMessage(), e ); } } else { pe = new OptimisticLockException( e.getMessage(), e ); } } else { pe = new OptimisticLockException( e.getMessage(), e ); } return pe; }