當前位置: 首頁>>代碼示例>>Java>>正文


Java EntityExistsException類代碼示例

本文整理匯總了Java中javax.persistence.EntityExistsException的典型用法代碼示例。如果您正苦於以下問題:Java EntityExistsException類的具體用法?Java EntityExistsException怎麽用?Java EntityExistsException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


EntityExistsException類屬於javax.persistence包,在下文中一共展示了EntityExistsException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: mapEJBExceptions

import javax.persistence.EntityExistsException; //導入依賴的package包/類
@Test(expected = ConcurrentModificationException.class)
public void mapEJBExceptions() throws Exception {
    mapper.mapEJBExceptions(new InvocationContextStub() {
        public Object proceed() throws Exception {
            throw new EJBException(new EntityExistsException());
        }
    });
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:9,代碼來源:ExceptionMapperTest.java

示例2: newPluginButtonActionPerformed

import javax.persistence.EntityExistsException; //導入依賴的package包/類
private void newPluginButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newPluginButtonActionPerformed
    PluginEditor dialog = new PluginEditor(new javax.swing.JFrame(), true);
    dialog.setVisible(true);
    while (dialog.isVisible()) {
        try {
            Thread.sleep(1000);
        } catch (InterruptedException ex) {
        	logger.error(ex.getMessage(),ex);
        }
    }
    if(dialog.getPlugin()==null) return;
    EntityManager em = emf.createEntityManager();
    em.getTransaction().begin();
    try {
        em.persist(dialog.getPlugin());
    } catch (EntityExistsException e) {
        javax.swing.JOptionPane.showMessageDialog(this, "The plugin is already registered!", "Warning", JOptionPane.WARNING_MESSAGE);
        em.getTransaction().rollback();
        em.close();
        return;
    }
    em.getTransaction().commit();
    em.close();
    inactivemodel.addElement(dialog.getPlugin());
}
 
開發者ID:ec-europa,項目名稱:sumo,代碼行數:26,代碼來源:PluginManagerDialog.java

示例3: create

import javax.persistence.EntityExistsException; //導入依賴的package包/類
public <T extends WithId<T>> T create(final T entity) {
    Kind kind = entity.getKind();
    Map<String, T> cache = caches.getCache(kind.getModelName());
    Optional<String> id = entity.getId();
    String idVal;

    final T entityToCreate;
    if (!id.isPresent()) {
        idVal = KeyGenerator.createKey();
        entityToCreate = entity.withId(idVal);
    } else {
        idVal = id.get();
        if (cache.containsKey(idVal)) {
            throw new EntityExistsException("There already exists a "
                + kind + " with id " + idVal);
        }
        entityToCreate = entity;
    }

    this.<T, T>doWithDataAccessObject(kind.getModelClass(), d -> d.create(entityToCreate));
    cache.put(idVal, entityToCreate);
    broadcast("created", kind.getModelName(), idVal);
    return entityToCreate;
}
 
開發者ID:syndesisio,項目名稱:syndesis,代碼行數:25,代碼來源:DataManager.java

示例4: updateWebServer

import javax.persistence.EntityExistsException; //導入依賴的package包/類
@Override
public WebServer updateWebServer(final WebServer webServer, final String createdBy) {
    try {
        final JpaWebServer jpaWebServer = findById(webServer.getId().getId());

        jpaWebServer.setName(webServer.getName());
        jpaWebServer.setHost(webServer.getHost());
        jpaWebServer.setPort(webServer.getPort());
        jpaWebServer.setHttpsPort(webServer.getHttpsPort());
        jpaWebServer.setStatusPath(webServer.getStatusPath().getPath());
        jpaWebServer.setCreateBy(createdBy);

        return webServerFrom(update(jpaWebServer));
    } catch (final EntityExistsException eee) {
        LOGGER.error("Error updating web server {}", webServer, eee);
        throw new EntityExistsException("Web Server Name already exists", eee);
    }
}
 
開發者ID:cerner,項目名稱:jwala,代碼行數:19,代碼來源:WebServerCrudServiceImpl.java

示例5: createApplication

import javax.persistence.EntityExistsException; //導入依賴的package包/類
@Override
public JpaApplication createApplication(CreateApplicationRequest createApplicationRequest, JpaGroup jpaGroup) {


    final JpaApplication jpaApp = new JpaApplication();
    jpaApp.setName(createApplicationRequest.getName());
    jpaApp.setGroup(jpaGroup);
    jpaApp.setWebAppContext(createApplicationRequest.getWebAppContext());
    jpaApp.setSecure(createApplicationRequest.isSecure());
    jpaApp.setLoadBalanceAcrossServers(createApplicationRequest.isLoadBalanceAcrossServers());
    jpaApp.setUnpackWar(createApplicationRequest.isUnpackWar());

    try {
        return create(jpaApp);
    } catch (final EntityExistsException eee) {
        LOGGER.error("Error creating app with request {} in group {}", createApplicationRequest, jpaGroup, eee);
        throw new EntityExistsException("App already exists: " + createApplicationRequest, eee);
    }
}
 
開發者ID:cerner,項目名稱:jwala,代碼行數:20,代碼來源:ApplicationCrudServiceImpl.java

示例6: updateApplication

import javax.persistence.EntityExistsException; //導入依賴的package包/類
@Override
public JpaApplication updateApplication(UpdateApplicationRequest updateApplicationRequest, JpaApplication jpaApp, JpaGroup jpaGroup) {

    final Identifier<Application> appId = updateApplicationRequest.getId();

    if (jpaApp != null) {
        jpaApp.setName(updateApplicationRequest.getNewName());
        jpaApp.setWebAppContext(updateApplicationRequest.getNewWebAppContext());
        jpaApp.setGroup(jpaGroup);
        jpaApp.setSecure(updateApplicationRequest.isNewSecure());
        jpaApp.setLoadBalanceAcrossServers(updateApplicationRequest.isNewLoadBalanceAcrossServers());
        jpaApp.setUnpackWar(updateApplicationRequest.isUnpackWar());
        try {
            return update(jpaApp);
        } catch (EntityExistsException eee) {
            LOGGER.error("Error updating application {} in group {}", jpaApp, jpaGroup, eee);
            throw new EntityExistsException("App already exists: " + updateApplicationRequest, eee);
        }
    } else {
        LOGGER.error("Application cannot be found {} attempting to update application", updateApplicationRequest);
        throw new BadRequestException(FaultType.INVALID_APPLICATION_NAME,
                "Application cannot be found: " + appId.getId());
    }
}
 
開發者ID:cerner,項目名稱:jwala,代碼行數:25,代碼來源:ApplicationCrudServiceImpl.java

示例7: testApplicationCrudServiceEEE

import javax.persistence.EntityExistsException; //導入依賴的package包/類
@Test(expected = EntityExistsException.class)
public void testApplicationCrudServiceEEE() {
    CreateApplicationRequest request = new CreateApplicationRequest(expGroupId, textName, textContext, true, true, false);

    JpaApplication created = applicationCrudService.createApplication(request, jpaGroup);

    assertNotNull(created);

    try {
        JpaApplication duplicate = applicationCrudService.createApplication(request, jpaGroup);
        fail(duplicate.toString());
    } catch (BadRequestException e) {
        assertEquals(FaultType.DUPLICATE_APPLICATION, e.getMessageResponseStatus());
        throw e;
    } finally {
        try {
            applicationCrudService.removeApplication(Identifier.<Application>id(created.getId())
            );
        } catch (Exception x) {
            LOGGER.trace("Test tearDown", x);
        }
    }

}
 
開發者ID:cerner,項目名稱:jwala,代碼行數:25,代碼來源:ApplicationCrudServiceImplTest.java

示例8: updateGroup

import javax.persistence.EntityExistsException; //導入依賴的package包/類
@Override
public Response updateGroup(final JsonUpdateGroup anUpdatedGroup,
                            final AuthenticatedUser aUser) {
    LOGGER.info("Update Group requested: {} by user {}", anUpdatedGroup, aUser.getUser().getId());
    try {
        // TODO: Refactor adhoc conversion to process group name instead of Id.
        final Group group = groupService.getGroup(anUpdatedGroup.getId());
        final JsonUpdateGroup updatedGroup = new JsonUpdateGroup(group.getId().getId().toString(),
                anUpdatedGroup.getName());

        return ResponseBuilder.ok(groupService.updateGroup(updatedGroup.toUpdateGroupCommand(),
                aUser.getUser()));
    } catch (EntityExistsException eee) {
        LOGGER.error("Group Name already exists: {}", anUpdatedGroup.getName(), eee);
        return ResponseBuilder.notOk(Response.Status.INTERNAL_SERVER_ERROR, new FaultCodeException(
                FaultType.DUPLICATE_GROUP_NAME, eee.getMessage(), eee));
    }
}
 
開發者ID:cerner,項目名稱:jwala,代碼行數:19,代碼來源:GroupServiceRestImpl.java

示例9: createGroup

import javax.persistence.EntityExistsException; //導入依賴的package包/類
@Override
@Transactional
public Group createGroup(final CreateGroupRequest createGroupRequest,
                         final User aCreatingUser) {
    createGroupRequest.validate();
    try {
        groupPersistenceService.getGroup(createGroupRequest.getGroupName());
        String message = MessageFormat.format("Group Name already exists: {0} ", createGroupRequest.getGroupName());
        LOGGER.error(message);
        throw new EntityExistsException(message);
    } catch (NotFoundException e) {
        LOGGER.debug("No group name conflict, ignoring not found exception for creating group ", e);
    }

    return groupPersistenceService.createGroup(createGroupRequest);
}
 
開發者ID:cerner,項目名稱:jwala,代碼行數:17,代碼來源:GroupServiceImpl.java

示例10: updateGroup

import javax.persistence.EntityExistsException; //導入依賴的package包/類
@Override
@Transactional
public Group updateGroup(final UpdateGroupRequest anUpdateGroupRequest,
                         final User anUpdatingUser) {
    anUpdateGroupRequest.validate();
    Group orginalGroup = getGroup(anUpdateGroupRequest.getId());
    try {
        if (!orginalGroup.getName().equalsIgnoreCase(anUpdateGroupRequest.getNewName()) && null != groupPersistenceService.getGroup(anUpdateGroupRequest.getNewName())) {
            String message = MessageFormat.format("Group Name already exists: {0}", anUpdateGroupRequest.getNewName());
            LOGGER.error(message);
            throw new EntityExistsException(message);
        }
    } catch (NotFoundException e) {
        LOGGER.debug("No group name conflict, ignoring not found exception for creating group ", e);
    }
    return groupPersistenceService.updateGroup(anUpdateGroupRequest);
}
 
開發者ID:cerner,項目名稱:jwala,代碼行數:18,代碼來源:GroupServiceImpl.java

示例11: createFolder

import javax.persistence.EntityExistsException; //導入依賴的package包/類
public void createFolder(Folder pFolder) throws FolderAlreadyExistsException, CreationException{
    try{
        //the EntityExistsException is thrown only when flush occurs          
        em.persist(pFolder);
        em.flush();
    }catch(EntityExistsException pEEEx){
        LOGGER.log(Level.FINEST,null,pEEEx);
        throw new FolderAlreadyExistsException(mLocale, pFolder);
    }catch(PersistenceException pPEx){
        //EntityExistsException is case sensitive
        //whereas MySQL is not thus PersistenceException could be
        //thrown instead of EntityExistsException
        LOGGER.log(Level.FINEST,null,pPEx);
        throw new CreationException(mLocale);
    }
}
 
開發者ID:polarsys,項目名稱:eplmp,代碼行數:17,代碼來源:FolderDAO.java

示例12: createPathToPathLink

import javax.persistence.EntityExistsException; //導入依賴的package包/類
public void createPathToPathLink(PathToPathLink pathToPathLink) throws CreationException, PathToPathLinkAlreadyExistsException {

        try {
            //the EntityExistsException is thrown only when flush occurs
            em.persist(pathToPathLink);
            em.flush();
        } catch (EntityExistsException pEEEx) {
            LOGGER.log(Level.FINEST,null,pEEEx);
            throw new PathToPathLinkAlreadyExistsException(mLocale, pathToPathLink);
        } catch (PersistenceException pPEx) {
            LOGGER.log(Level.FINEST,null,pPEx);
            //EntityExistsException is case sensitive
            //whereas MySQL is not thus PersistenceException could be
            //thrown instead of EntityExistsException
            throw new CreationException(mLocale);
        }
    }
 
開發者ID:polarsys,項目名稱:eplmp,代碼行數:18,代碼來源:PathToPathLinkDAO.java

示例13: createDocM

import javax.persistence.EntityExistsException; //導入依賴的package包/類
public void createDocM(DocumentMaster pDocumentMaster) throws DocumentMasterAlreadyExistsException, CreationException {
    try {
        //the EntityExistsException is thrown only when flush occurs
        em.persist(pDocumentMaster);
        em.flush();
    } catch (EntityExistsException pEEEx) {
        LOGGER.log(Level.FINER,null,pEEEx);
        throw new DocumentMasterAlreadyExistsException(mLocale, pDocumentMaster);
    } catch (PersistenceException pPEx) {
        //EntityExistsException is case sensitive
        //whereas MySQL is not thus PersistenceException could be
        //thrown instead of EntityExistsException
        LOGGER.log(Level.FINER,null,pPEx);
        throw new CreationException(mLocale);
    }
}
 
開發者ID:polarsys,項目名稱:eplmp,代碼行數:17,代碼來源:DocumentMasterDAO.java

示例14: createQuery

import javax.persistence.EntityExistsException; //導入依賴的package包/類
public void createQuery(Query query) throws CreationException, QueryAlreadyExistsException {
    try {

        QueryRule queryRule = query.getQueryRule();

        if(queryRule != null){
            persistQueryRules(queryRule);
        }

        QueryRule pathDataQueryRule = query.getPathDataQueryRule();

        if (pathDataQueryRule != null) {
            persistQueryRules(pathDataQueryRule);
        }

        em.persist(query);
        em.flush();
        persistContexts(query, query.getContexts());
    } catch (EntityExistsException pEEEx) {
        LOGGER.log(Level.FINEST, null, pEEEx);
        throw new QueryAlreadyExistsException(mLocale, query);
    } catch (PersistenceException pPEx) {
        LOGGER.log(Level.FINEST, null, pPEx);
        throw new CreationException(mLocale);
    }
}
 
開發者ID:polarsys,項目名稱:eplmp,代碼行數:27,代碼來源:QueryDAO.java

示例15: createOrganization

import javax.persistence.EntityExistsException; //導入依賴的package包/類
public void createOrganization(Organization pOrganization) throws OrganizationAlreadyExistsException, CreationException {
    try {
        //the EntityExistsException is thrown only when flush occurs
        if (pOrganization.getName().trim().equals(""))
            throw new CreationException(mLocale);
        em.persist(pOrganization);
        em.flush();
    } catch (EntityExistsException pEEEx) {
        throw new OrganizationAlreadyExistsException(mLocale, pOrganization);
    } catch (PersistenceException pPEx) {
        //EntityExistsException is case sensitive
        //whereas MySQL is not thus PersistenceException could be
        //thrown instead of EntityExistsException
        throw new CreationException(mLocale);
    }
}
 
開發者ID:polarsys,項目名稱:eplmp,代碼行數:17,代碼來源:OrganizationDAO.java


注:本文中的javax.persistence.EntityExistsException類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。