Package javax.persistence

Examples of javax.persistence.EntityExistsException


      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


                altName, email, type, endEntityProfileId, userDataVO.getCertificateProfileId(),
                userDataVO.getTokenType(), userDataVO.getHardTokenIssuerId(), userDataVO.getExtendedinformation());
            // Since persist will not commit and fail if the user already exists, we need to check for this
            // Flushing the entityManager will not allow us to rollback the persisted user if this is a part of a larger transaction.
            if (UserData.findByUsername(entityManager, username) != null) {
              throw new EntityExistsException("User " + username + " already exists.");
            }
            entityManager.persist(userData);
            // Although UserDataVO should always have a null password for
            // autogenerated end entities, the notification framework
            // expect it to exist. Since nothing else but printing is done after
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

    }

    public Subject createSubject(Subject whoami, Subject subjectToCreate, String password) throws SubjectException,
        EntityExistsException {
        if (getSubjectByName(subjectToCreate.getName()) != null) {
            throw new EntityExistsException("A user named [" + subjectToCreate.getName() + "] already exists.");
        }

        if (subjectToCreate.getFsystem()) {
            throw new SubjectException("Cannot create new system users: " + subjectToCreate.getName());
        }
View Full Code Here

     */
    @RequiredPermission(Permission.MANAGE_SECURITY)
    public Subject createSubject(Subject whoami, Subject subject) throws SubjectException {
        // Make sure there's not an existing subject with the same name.
        if (getSubjectByName(subject.getName()) != null) {
            throw new EntityExistsException("A user named [" + subject.getName() + "] already exists.");
        }

        if (subject.getFsystem()) {
            throw new SubjectException("Cannot create new system subjects: " + subject.getName());
        }
View Full Code Here

        RoleCriteria criteria = new RoleCriteria();
        criteria.addFilterName(newRole.getName());
        criteria.setStrict(true);
        PageList<Role> roles = findRolesByCriteria(whoami, criteria);
        if (!roles.isEmpty()) {
            throw new EntityExistsException("A user role [" + newRole.getName() + "] already exists.");
        }

        Boolean isSystemRole = newRole.getFsystem();
        if (isSystemRole) {
            throw new IllegalArgumentException("Unable to create system role [" + newRole.getName()
View Full Code Here

    OptimisticLockException optimisticLock = new OptimisticLockException();
    assertSame(JpaOptimisticLockingFailureException.class,
        EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(optimisticLock).getClass());

    EntityExistsException entityExists = new EntityExistsException("foo");
    assertSame(DataIntegrityViolationException.class,
        EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(entityExists).getClass());

    TransactionRequiredException transactionRequired = new TransactionRequiredException("foo");
    assertSame(InvalidDataAccessApiUsageException.class,
View Full Code Here

            if (om.getApiAdapter().isDetached(entity))
            {
                // The JPA spec is very confused about when this exception is thrown, however the JPA TCK
                // invokes this operation multiple times over the same instance
                // Entity is already persistent. Maybe the ObjectManager.exists method isnt the best way of checking
                throwException(new EntityExistsException(LOCALISER.msg("EM.EntityIsPersistent", StringUtils.toJVMIDString(entity))));
            }
        }

        try
        {
View Full Code Here

        }

        AttributableUtil attrUtil = getAttributableUtil(kind);

        if (virSchemaDAO.find(virSchemaTO.getName(), attrUtil.virSchemaClass()) != null) {
            throw new EntityExistsException(attrUtil.schemaClass().getSimpleName()
                    + " '" + virSchemaTO.getName() + "'");
        }

        AbstractVirSchema virSchema = virSchemaDAO.save(binder.create(virSchemaTO, attrUtil.newVirSchema()));
        response.setStatus(HttpServletResponse.SC_CREATED);
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.