Package javax.persistence

Examples of javax.persistence.PersistenceException


                StringUtils.toJVMIDString(entity), "" + om.getApiAdapter().getIdForObject(entity)));
        }
        if (!contains(entity))
        {
            // The object is not contained (the javadoc doesnt explicitly say which exception to throw here)
            throw new PersistenceException("Entity is not contained in this persistence context so cant lock it");
        }

        // TODO Implement lock()
    }
View Full Code Here


        if (jdoe instanceof JDODataStoreException)
        {
            // JPA doesnt have "datastore" exceptions so just give a PersistenceException
            if (jdoe.getNestedExceptions() != null)
            {
                return new PersistenceException(jdoe.getMessage(), jdoe.getCause());
            }
            else
            {
                return new PersistenceException(jdoe.getMessage(), jdoe);
            }
        }
        else if (jdoe instanceof JDOObjectNotFoundException)
        {
            return new EntityNotFoundException(jdoe.getMessage());
        }
        else if (jdoe instanceof JDOUserException)
        {
            // JPA doesnt have "user" exceptions so just give a PersistenceException
            if (jdoe.getNestedExceptions() != null)
            {
                return new PersistenceException(jdoe.getMessage(), jdoe.getCause());
            }
            else
            {
                return new PersistenceException(jdoe.getMessage(), jdoe);
            }
        }
        else if (jdoe instanceof JDOOptimisticVerificationException)
        {
            if (jdoe.getNestedExceptions() != null)
            {
                return new OptimisticLockException(jdoe.getMessage(), jdoe.getCause());
            }
            else
            {
                return new OptimisticLockException(jdoe.getMessage(), jdoe);
            }
        }
        else
        {
            // JPA doesnt have "internal" exceptions so just give a PersistenceException
            if (jdoe.getNestedExceptions() != null)
            {
                return new PersistenceException(jdoe.getMessage(), jdoe.getCause());
            }
            else
            {
                return new PersistenceException(jdoe.getMessage(), jdoe);
            }
        }
    }
View Full Code Here

        else if (jpe instanceof JPOXDataStoreException)
        {
            // JPA doesnt have "datastore" exceptions so just give a PersistenceException
            if (jpe.getNestedExceptions() != null)
            {
                return new PersistenceException(jpe.getMessage(), jpe.getCause());
            }
            else
            {
                return new PersistenceException(jpe.getMessage(), jpe);
            }
        }
        else if (jpe instanceof JPOXObjectNotFoundException)
        {
            return new EntityNotFoundException(jpe.getMessage());
        }
        else if (jpe instanceof JPOXUserException)
        {
            // JPA doesnt have "user" exceptions so just give a PersistenceException
            if (jpe.getNestedExceptions() != null)
            {
                return new PersistenceException(jpe.getMessage(), jpe.getCause());
            }
            else
            {
                return new PersistenceException(jpe.getMessage(), jpe);
            }
        }
        else if (jpe instanceof JPOXOptimisticException)
        {
            if (jpe.getNestedExceptions() != null)
            {
                return new OptimisticLockException(jpe.getMessage(), jpe.getCause());
            }
            else
            {
                return new OptimisticLockException(jpe.getMessage(), jpe);
            }
        }
        else
        {
            // JPA doesnt have "internal" exceptions so just give a PersistenceException
            if (jpe.getNestedExceptions() != null)
            {
                return new PersistenceException(jpe.getMessage(), jpe.getCause());
            }
            else
            {
                return new PersistenceException(jpe.getMessage(), jpe);
            }
        }
    }
View Full Code Here

      rollback();
    } catch (Exception e1) {
      log.log(Level.FINE, e1.toString(), e1);
    }

    return new PersistenceException(e);
  }
View Full Code Here

      _rollbackOnly = false;

      try {
        AmberConnection.this.beginTransaction();
      } catch (SQLException e) {
        throw new PersistenceException(e);
      }
    }
View Full Code Here

        if (AmberConnection.this._conn != null) {
          closeConnectionImpl();
        }
      } catch (SQLException e) {
        throw new PersistenceException(e);
      }
    }
View Full Code Here

      if (! isActiveTransaction())
        throw new IllegalStateException("rollback() cannot be called when the entity transaction is not active.");

      setRollbackOnly();

      PersistenceException exn = null;

      try {
        AmberConnection.this.rollback();
      } catch (Exception e) {
        exn = new PersistenceException(e);
      } finally {
        try {
          // jpa/1501
          AmberConnection.this.afterCommit(false);
        } catch (PersistenceException e) {
          exn = e;
        } catch (Exception e) {
          exn = new PersistenceException(e);
        } finally {
          // jpa/1525
          if (AmberConnection.this._conn != null) {
            closeConnectionImpl();
          }
View Full Code Here

            Class clazz = classLoader.loadClass(persistenceProviderClassName);
            PersistenceProvider persistenceProvider = (PersistenceProvider) clazz.newInstance();
            entityManagerFactory = persistenceProvider.createContainerEntityManagerFactory(persistenceUnitInfo, properties);
        } catch (ClassNotFoundException e) {
            persistenceUnitInfo.destroy();
            throw new PersistenceException("Could not locate PersistenceProvider class: " + persistenceProviderClassName + " in classloader " + classLoader, e);
        } catch (InstantiationException e) {
            persistenceUnitInfo.destroy();
            throw new PersistenceException("Could not create PersistenceProvider instance: " + persistenceProviderClassName + " loaded from classloader " + classLoader, e);
        } catch (IllegalAccessException e) {
            persistenceUnitInfo.destroy();
            throw new PersistenceException("Could not create PersistenceProvider instance: " + persistenceProviderClassName + " loaded from classloader " + classLoader, e);
        }
        this.transactionManager = transactionManager;
        this.entityManagerRegistry = new SingleElementCollection<ExtendedEntityManagerRegistry>(entityManagerRegistry);
    }
View Full Code Here

    }
    catch (PersistenceException pe) {
      throw pe;
    }
    catch (Exception e) {
      throw new PersistenceException( "Unable to build EntityManagerFactory", e );
    }
  }
View Full Code Here

                    holder.result = result;
                    holder.exchange = createExchange(result);
                    answer.add(holder);
                }

                PersistenceException cause = null;
                int messagePolled = 0;
                try {
                    messagePolled = processBatch(CastUtils.cast(answer));
                } catch (Exception e) {
                    if (e instanceof PersistenceException) {
                        cause = (PersistenceException) e;
                    } else {
                        cause = new PersistenceException(e);
                    }
                }

                if (cause != null) {
                    if (!isTransacted()) {
                        LOG.warn("Error processing last message due: {}. Will commit all previous successful processed message, and ignore this last failure.", cause.getMessage(), cause);
                    } else {
                        // rollback all by throwning exception
                        throw cause;
                    }
                }
View Full Code Here

TOP

Related Classes of javax.persistence.PersistenceException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.