Package javax.persistence

Examples of javax.persistence.EntityExistsException


            }
            try {
                getActivePersistenceContext(checkForTransaction(!isExtended())).registerNewObjectForPersist(entity, new IdentityHashMap());
            } catch (RuntimeException e) {
                if (ValidationException.class.isAssignableFrom(e.getClass())) {
                    throw new EntityExistsException(e.getLocalizedMessage(), e);
                }
                throw e;
            }
        } catch (RuntimeException e) {
            setRollbackOnly();
View Full Code Here


            txn.commit();
            ub.clear();
            return result;
        } catch (final SQLException e) {
            if (e.getSQLState().equals("23000") && e.getErrorCode() == 1062) {
                throw new EntityExistsException("Entity already exists ", e);
            }
            throw new CloudRuntimeException("DB Exception on: " + pstmt, e);
        }
    }
View Full Code Here

                insertElementCollection(entity, _idAttributes.get(_table)[0], id, ecAttributes);
            }
            txn.commit();
        } catch (final SQLException e) {
            if (e.getSQLState().equals("23000") && e.getErrorCode() == 1062) {
                throw new EntityExistsException("Entity already exists: ", e);
            } else {
                throw new CloudRuntimeException("DB Exception on: " + pstmt, e);
            }
        } catch (IllegalArgumentException e) {
            throw new CloudRuntimeException("Problem with getting the ec attribute ", e);
View Full Code Here

            }
            try {
                getActivePersistenceContext(checkForTransaction(false)).registerNewObjectForPersist(entity, new IdentityHashMap());
            } catch (RuntimeException exception) {
                if (exception instanceof ValidationException) {
                    throw new EntityExistsException(exception.getLocalizedMessage(), exception);
                }
                throw exception;
            }
        } catch (RuntimeException exception) {
            setRollbackOnly();
View Full Code Here

        // FALLTHROUGH
      case MANAGED:
        // no-op, but cascade to relatives
        break;
      case DETACHED:
        throw new EntityExistsException();
      }
      break;
    case DETACHED:
      switch (oldState) {
      case NEW:
View Full Code Here

            txn.commit();
            ub.clear();
            return result;
        } catch (final SQLException e) {
            if (e.getSQLState().equals("23000") && e.getErrorCode() == 1062) {
                throw new EntityExistsException("Entity already exists ", e);
            }
            throw new CloudRuntimeException("DB Exception on: " + pstmt, e);
        }
    }
View Full Code Here

                insertElementCollection(entity, _idAttributes.get(_table)[0], id, ecAttributes);
            }
            txn.commit();
        } catch (final SQLException e) {
            if (e.getSQLState().equals("23000") && e.getErrorCode() == 1062) {
                throw new EntityExistsException("Entity already exists: ", e);
            } else {
                throw new CloudRuntimeException("DB Exception on: " + pstmt, e);
            }
        } catch (IllegalArgumentException e) {
            throw new CloudRuntimeException("Problem with getting the ec attribute ", e);
View Full Code Here

      EntityNotFoundException converted = new EntityNotFoundException( e.getMessage() );
      handlePersistenceException( converted );
      return converted;
    }
        else if ( e instanceof org.hibernate.NonUniqueObjectException ) {
            EntityExistsException converted = new EntityExistsException( e.getMessage() );
            handlePersistenceException( converted );
            return converted;
        }
    else if ( e instanceof org.hibernate.NonUniqueResultException ) {
      NonUniqueResultException converted = new NonUniqueResultException( e.getMessage() );
View Full Code Here

      PersistenceException converted = wrapLockException( (HibernateException) e, null );
      throwPersistenceException( converted );
    }
    else if ( e instanceof ConstraintViolationException ) {
      //FIXME this is bad cause ConstraintViolationException happens in other circumstances
      throwPersistenceException( new EntityExistsException( e ) );
    }
    else if ( e instanceof org.hibernate.QueryTimeoutException ) {
      javax.persistence.QueryTimeoutException converted = new javax.persistence.QueryTimeoutException(e.getMessage(), e);
      throwPersistenceException( converted );
    }
View Full Code Here

            em.createQuery("from FacilityModel f where f.facilityId = :fid")
            .setParameter("fid", facilityId)
            .getSingleResult();
           
            // すでに存在している場合は例外をスローする
            throw new EntityExistsException();
           
        } catch (NoResultException e) {
            // 当たり前
        }
       
View Full Code Here

TOP

Related Classes of javax.persistence.EntityExistsException

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.