/** * Throw exception for failures. */ private void throwExceptions(List exceps, List failed, boolean opt) { if (exceps == null) return; if (exceps.size() == 1) throw (RuntimeException) exceps.get(0); Throwable[] t = (Throwable[]) exceps.toArray (new Throwable[exceps.size()]); if (opt && failed != null) throw new OptimisticException(failed, t); if (opt) throw new OptimisticException(t); throw new UserException(_loc.get("nested-exceps")). setNestedThrowables(t); }
public OptimisticException(Object failed) { this(_loc.get("opt-lock", Exceptions.toString(failed))); setFailedObject(failed); }
/** * Throw the proper exception based on the given set of flush errors, or * do nothing if no errors occurred. */ private OpenJPAException newFlushException(Collection exceps) { if (exceps == null || exceps.isEmpty()) return null; Throwable[] t = (Throwable[]) exceps.toArray (new Throwable[exceps.size()]); List failed = new ArrayList(t.length); // create fatal exception with nested exceptions for all the failed // objects; if all OL exceptions, throw a top-level OL exception boolean opt = true; for (int i = 0; opt && i < t.length; i++) { opt = t[i] instanceof OptimisticException; if (opt) { Object f = ((OptimisticException) t[i]).getFailedObject(); if (f != null) failed.add(f); } } if (opt && !failed.isEmpty()) return new OptimisticException(failed, t); if (opt) return new OptimisticException(t); return new StoreException(_loc.get("rolled-back")). setNestedThrowables(t).setFatal(true); }
protected void optimisticLockInternal(OpenJPAStateManager sm, int level, int timeout, Object sdata, boolean postLockVersionCheck) { super.optimisticLockInternal(sm, level, timeout, sdata, postLockVersionCheck); if (postLockVersionCheck) { if (level >= MixedLockLevels.LOCK_PESSIMISTIC_READ) { ClassMapping mapping = (ClassMapping) sm.getMetaData(); try { if (!mapping.getVersion().checkVersion(sm, this.getStore(), false)) { throw (new OptimisticException(_loc.get( "optimistic-violation-lock").getMessage())) .setFailedObject(sm.getObjectId()); } } catch (SQLException se) { throw SQLExceptions.getStore(se, sm.getObjectId(), getStore().getDBDictionary()); } } } }
public OptimisticException(Throwable[] nested) { this(_loc.get("opt-lock-nested")); setNestedThrowables(nested); }
public Object[] attachAll(Collection objs, boolean copyNew, OpCallbacks call) { if (objs == null) return null; if (objs.isEmpty()) return EMPTY_OBJECTS; beginOperation(true); try { // make sure not to try to set rollback only if this fails assertWriteOperation(); try { return new AttachManager(this, copyNew, call).attachAll(objs); } catch (OptimisticException oe) { setRollbackOnly(oe); throw oe.setFatal(true); } catch (OpenJPAException ke) { throw ke; } catch (RuntimeException re) { throw new GeneralException(re); } } finally { endOperation(); } }
Object o = e.getFailedObject(); OpenJPAStateManager sm = _ctx.getStateManager(o); if (sm == null)
protected void optimisticLockInternal(OpenJPAStateManager sm, int level, int timeout, Object sdata, boolean postLockVersionCheck) { super.optimisticLockInternal(sm, level, timeout, sdata, postLockVersionCheck); if (postLockVersionCheck) { if (level >= MixedLockLevels.LOCK_PESSIMISTIC_READ) { ClassMapping mapping = (ClassMapping) sm.getMetaData(); try { if (!mapping.getVersion().checkVersion(sm, this.getStore(), false)) { throw (new OptimisticException(_loc.get( "optimistic-violation-lock").getMessage())) .setFailedObject(sm.getObjectId()); } } catch (SQLException se) { throw SQLExceptions.getStore(se, sm.getObjectId(), getStore().getDBDictionary()); } } } }
public OptimisticException(Throwable[] nested) { this(_loc.get("opt-lock-nested")); setNestedThrowables(nested); }
public Object[] attachAll(Collection objs, boolean copyNew, OpCallbacks call) { if (objs == null) return null; if (objs.isEmpty()) return EMPTY_OBJECTS; beginOperation(true); try { // make sure not to try to set rollback only if this fails assertWriteOperation(); try { return new AttachManager(this, copyNew, call).attachAll(objs); } catch (OptimisticException oe) { setRollbackOnly(oe); throw oe.setFatal(true); } catch (OpenJPAException ke) { throw ke; } catch (RuntimeException re) { throw new GeneralException(re); } } finally { endOperation(); } }
Object o = e.getFailedObject(); OpenJPAStateManager sm = _ctx.getStateManager(o); if (sm == null)
protected void optimisticLockInternal(OpenJPAStateManager sm, int level, int timeout, Object sdata, boolean postLockVersionCheck) { super.optimisticLockInternal(sm, level, timeout, sdata, postLockVersionCheck); if (postLockVersionCheck) { if (level >= MixedLockLevels.LOCK_PESSIMISTIC_READ) { ClassMapping mapping = (ClassMapping) sm.getMetaData(); try { if (!mapping.getVersion().checkVersion(sm, this.getStore(), false)) { throw (new OptimisticException(_loc.get( "optimistic-violation-lock").getMessage())) .setFailedObject(sm.getObjectId()); } } catch (SQLException se) { throw SQLExceptions.getStore(se, sm.getObjectId(), getStore().getDBDictionary()); } } } }
/** * Throw exception for failures. */ private void throwExceptions(List exceps, List failed, boolean opt) { if (exceps == null) return; if (exceps.size() == 1) throw (RuntimeException) exceps.get(0); Throwable[] t = (Throwable[]) exceps.toArray (new Throwable[exceps.size()]); if (opt && failed != null) throw new OptimisticException(failed, t); if (opt) throw new OptimisticException(t); throw new UserException(_loc.get("nested-exceps")). setNestedThrowables(t); }
opt = t[i] instanceof OptimisticException; if (opt) { Object f = ((OptimisticException) t[i]).getFailedObject(); if (f != null) failed.add(f); return new OptimisticException(_loc.get("broker-suppressing-exceptions",t.length)); }else{ return new OptimisticException(failed, t); return new OptimisticException(t);
public OptimisticException(Throwable[] nested) { this(_loc.get("opt-lock-nested")); setNestedThrowables(nested); }
public Object[] attachAll(Collection objs, boolean copyNew, OpCallbacks call) { if (objs == null) return null; if (objs.isEmpty()) return EMPTY_OBJECTS; beginOperation(true); try { // make sure not to try to set rollback only if this fails assertWriteOperation(); try { return new AttachManager(this, copyNew, call).attachAll(objs); } catch (OptimisticException oe) { setRollbackOnly(oe); throw oe.setFatal(true); } catch (OpenJPAException ke) { throw ke; } catch (RuntimeException re) { throw new GeneralException(re); } } finally { endOperation(); } }
public OptimisticException(Object failed) { this(_loc.get("opt-lock", Exceptions.toString(failed))); setFailedObject(failed); }
Object o = e.getFailedObject(); OpenJPAStateManager sm = _ctx.getStateManager(o); if (sm == null)
protected void optimisticLockInternal(OpenJPAStateManager sm, int level, int timeout, Object sdata, boolean postLockVersionCheck) { super.optimisticLockInternal(sm, level, timeout, sdata, postLockVersionCheck); if (postLockVersionCheck) { if (level >= MixedLockLevels.LOCK_PESSIMISTIC_READ) { ClassMapping mapping = (ClassMapping) sm.getMetaData(); try { if (!mapping.getVersion().checkVersion(sm, this.getStore(), false)) { throw (new OptimisticException(_loc.get( "optimistic-violation-lock").getMessage())) .setFailedObject(sm.getObjectId()); } } catch (SQLException se) { throw SQLExceptions.getStore(se, sm.getObjectId(), getStore().getDBDictionary()); } } } }
/** * Throw exception for failures. */ private void throwExceptions(List exceps, List failed, boolean opt) { if (exceps == null) return; if (exceps.size() == 1) throw (RuntimeException) exceps.get(0); Throwable[] t = (Throwable[]) exceps.toArray (new Throwable[exceps.size()]); if (opt && failed != null) throw new OptimisticException(failed, t); if (opt) throw new OptimisticException(t); throw new UserException(_loc.get("nested-exceps")). setNestedThrowables(t); }