List of usage examples for javax.persistence PersistenceException PersistenceException
public PersistenceException(String message, Throwable cause)
PersistenceException
exception with the specified detail message and cause. From source file:com.impetus.kundera.ejb.PersistenceXmlLoader.java
/** * Gets the document.// w w w . j a v a 2 s . co m * * @param configURL * the config url * @return the document * @throws Exception * the exception */ private static Document getDocument(URL configURL) throws Exception { InputStream is = null; if (configURL != null) { URLConnection conn = configURL.openConnection(); conn.setUseCaches(false); // avoid JAR locking on Windows and Tomcat is = conn.getInputStream(); } if (is == null) { throw new IOException("Failed to obtain InputStream from url: " + configURL); } DocumentBuilderFactory docBuilderFactory = null; docBuilderFactory = DocumentBuilderFactory.newInstance(); docBuilderFactory.setValidating(true); docBuilderFactory.setNamespaceAware(true); try { // otherwise Xerces fails in validation docBuilderFactory.setAttribute("http://apache.org/xml/features/validation/schema", true); } catch (IllegalArgumentException e) { docBuilderFactory.setValidating(false); docBuilderFactory.setNamespaceAware(false); } InputSource source = new InputSource(is); DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder(); // docBuilder.setEntityResolver( resolver ); List errors = new ArrayList(); docBuilder.setErrorHandler(new ErrorLogger("XML InputStream", errors)); Document doc = docBuilder.parse(source); if (errors.size() != 0) { throw new PersistenceException("invalid persistence.xml", (Throwable) errors.get(0)); } is.close(); //Close input Stream return doc; }
From source file:org.spring.data.gemfire.app.dao.vendor.SQLFireJpaUserDao.java
@Override protected EntityManager prepare(final EntityManager entityManager) { Assert.notNull(entityManager, "The JPA EntityManager must not be null!"); Assert.state(entityManager.isOpen(), "The EntityManager is closed!"); if (entityManager.getDelegate() instanceof Session) { Session session = (Session) entityManager.getDelegate(); if (session instanceof SessionImpl) { try { ((SessionImpl) session).connection() .setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED); //((SessionImpl) session).connection().setTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED); //((SessionImpl) session).connection().setTransactionIsolation(Connection.TRANSACTION_REPEATABLE_READ); //((SessionImpl) session).connection().setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE); //((SessionImpl) session).connection().setTransactionIsolation(Connection.TRANSACTION_NONE); } catch (SQLException e) { //System.err.printf("Failed to set the JDBC Connection Transaction Isolation Level to (READ_COMMITTED)!%n%1$s%n", e); throw new PersistenceException( "Failed to set the JDBC Connection Transaction Isolation-level to (READ_COMMITTED)!", e);/* w w w . j a va2 s . c om*/ } } } return entityManager; }
From source file:com.impetus.kundera.proxy.cglib.CglibLazyInitializer.java
/** * Gets the proxy.//from w ww . j a v a 2s . com * * @param entityName * the entity name * @param persistentClass * the persistent class * @param interfaces * the interfaces * @param getIdentifierMethod * the get identifier method * @param setIdentifierMethod * the set identifier method * @param id * the id * @param em * the em * @return the proxy * @throws PersistenceException * the persistence exception */ public static KunderaProxy getProxy(final String entityName, final Class<?> persistentClass, final Class<?>[] interfaces, final Method getIdentifierMethod, final Method setIdentifierMethod, final String id, final EntityManagerImpl em) throws PersistenceException { try { final CglibLazyInitializer instance = new CglibLazyInitializer(entityName, persistentClass, interfaces, id, getIdentifierMethod, setIdentifierMethod, em); final KunderaProxy proxy; Class factory = getProxyFactory(persistentClass, interfaces); proxy = getProxyInstance(factory, instance); instance.constructed = true; return proxy; } catch (Throwable t) { throw new PersistenceException("CGLIB Enhancement failed: " + entityName, t); } }
From source file:com.openmeap.model.ModelManagerImpl.java
@Override public ModelManager begin() { try {/* ww w .jav a 2 s . c o m*/ fileManager.begin(); } catch (FileOperationException e) { throw new PersistenceException( "An exception was thrown creating a file-resource transaction: " + e.getMessage(), e); } modelService.begin(); return this; }
From source file:com.netflix.paas.dao.astyanax.AstyanaxDao.java
@Override public void createTable() throws PersistenceException { try {//ww w . j a v a 2s . co m keyspace.createColumnFamily(columnFamily, null); } catch (ConnectionException e) { throw new PersistenceException("Failed to create column family : " + columnFamily.getName(), e); } }
From source file:com.netflix.paas.dao.astyanax.AstyanaxDao.java
@Override public void deleteTable() throws PersistenceException { try {//from www . j a va 2s . c om keyspace.dropColumnFamily(columnFamily); } catch (ConnectionException e) { throw new PersistenceException("Failed to drop column family : " + columnFamily.getName(), e); } }
From source file:com.openmeap.model.ModelManagerImpl.java
@Override public ModelManager commit(List<ProcessingEvent> events) throws PersistenceException { processModelEntityEventQueue(CutPoint.IN_COMMIT_BEFORE_COMMIT, events); try {/* www . ja va2s. c om*/ if (fileManager.isTransactionActive()) { fileManager.commit(); } } catch (FileOperationException e) { throw new PersistenceException( "An exception was thrown commiting a file-resource transaction: " + e.getMessage(), e); } modelService.commit(); processModelEntityEventQueue(CutPoint.IN_COMMIT_AFTER_COMMIT, events); clearModelEntityEventQueue(); return this; }
From source file:com.tesora.dve.common.catalog.CatalogDAO.java
public void rollback(Throwable t) { try {/*from w w w .j a va2s . c om*/ if (em.get().getTransaction().isActive()) rollbackNoException(); } catch (Throwable rollbackT) { logger.warn("Exception during rollback", rollbackT); throw new PersistenceException("Exception during rollback (check log for rollback exception)", t); } }
From source file:com.openmeap.model.ModelManagerImpl.java
@Override public void rollback() throws PersistenceException { clearModelEntityEventQueue();//from w w w . j a v a 2 s . c o m try { if (fileManager.isTransactionActive()) { fileManager.rollback(); } } catch (FileOperationException e) { throw new PersistenceException( "An exception was thrown rolling back a file-resource transaction:" + e.getMessage(), e); } modelService.rollback(); }