/** * Throws a {@link StoreException} by default. */ public void handleCheckedException(Exception e) { throw new StoreException (e); } }
/** * Convert the specified exception into a {@link StoreException}. */ public static OpenJPAException getStore(String msg, SQLException se, Object failed, DBDictionary dict) { if (msg == null) msg = se.getClass().getName(); SQLException[] ses = getSQLExceptions(se); if (dict == null) return new StoreException(msg).setFailedObject(failed). setNestedThrowables(ses); return dict.newStoreException(msg, ses, failed); }
public String toString() { String str = super.toString(); if (timeout < 0) return str; return str + Exceptions.SEP + "Query Timeout: " + timeout; }
/** * Create the dictionary using connection metadata to determine its type. */ public static DBDictionary newDBDictionary(JDBCConfiguration conf, DataSource ds, String props) { Connection conn = null; try { conn = ds.getConnection(); DatabaseMetaData meta = conn.getMetaData(); String dclass = dictionaryClassForString(meta.getURL(), conf); if (dclass == null) dclass = dictionaryClassForString (meta.getDatabaseProductName(), conf); if (dclass == null) dclass = DBDictionary.class.getName(); return newDBDictionary(conf, dclass, props, conn); } catch (SQLException se) { throw new StoreException(se).setFatal(true); } finally { if (conn != null) try { conn.close(); } catch (SQLException se) { } } }
/** * 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); }
err = new StoreException(_loc.get("marked-rollback")). setCause(_rollbackOnly).setFatal(true);
return newDBDictionary(conf, dclass, props, conn); } catch (SQLException se) { throw new StoreException(se).setFatal(true); } finally { if (conn != null)
return new StoreException(_loc.get("rolled-back")). setNestedThrowables(t).setFatal(true).setFailedObject(failedObject);
err = new StoreException(_loc.get("marked-rollback")). setCause(_rollbackOnly).setFatal(true);
return newDBDictionary(conf, dclass, props, conn); } catch (SQLException se) { throw new StoreException(se).setFatal(true); } finally { if (conn != null)
/** * Throws a {@link StoreException} by default. */ public void handleCheckedException(Exception e) { throw new StoreException (e); } }
/** * Return a new exception that wraps <code>causes</code>. * However, the details of exactly what type of exception is returned can * be determined by the implementation. This may take into account * DB-specific exception information in <code>causes</code>. */ public OpenJPAException newStoreException(String msg, SQLException[] causes, Object failed) { if (causes != null && causes.length > 0) { OpenJPAException ret = narrow(msg, causes[0], failed); ret.setFailedObject(failed).setNestedThrowables(causes); return ret; } return new StoreException(msg).setFailedObject(failed). setNestedThrowables(causes); }
return new StoreException(_loc.get("rolled-back")). setNestedThrowables(t).setFatal(true).setFailedObject(failedObject);
err = new StoreException(_loc.get("marked-rollback")). setCause(_rollbackOnly).setFatal(true);
public String toString() { String str = super.toString(); if (timeout < 0) return str; return str + Exceptions.SEP + "Timeout: " + timeout + ", LockLevel" + lockLevel; }
return newDBDictionary(conf, dclass, props, conn); } catch (SQLException se) { throw new StoreException(se).setFatal(true); } finally { if (conn != null)
/** * Throws a {@link StoreException} by default. */ public void handleCheckedException(Exception e) { throw new StoreException (e); } }
/** * Return a new exception that wraps <code>causes</code>. * However, the details of exactly what type of exception is returned can * be determined by the implementation. This may take into account * DB-specific exception information in <code>causes</code>. */ public OpenJPAException newStoreException(String msg, SQLException[] causes, Object failed) { if (causes != null && causes.length > 0) { OpenJPAException ret = SQLExceptions.narrow(msg, causes[0], this); ret.setFailedObject(failed).setNestedThrowables(causes); return ret; } return new StoreException(msg).setFailedObject(failed). setNestedThrowables(causes); }
return new StoreException(_loc.get("rolled-back")). setNestedThrowables(t).setFatal(true).setFailedObject(failedObject);
err = new StoreException(_loc.get("marked-rollback")). setCause(_rollbackOnly).setFatal(true);