Package javax.persistence

Examples of javax.persistence.NoResultException


            @Override
            public Page answer() throws Throwable {
                return (Page)EasyMock.getCurrentArguments()[0];
            }
        });
        expect(pageTemplateRepository.getDefaultPage(PageType.USER)).andThrow(new NoResultException("No Result Exception"));

        expect(pageRepository.getAllPages(user.getId(), PageType.USER)).andReturn(new ArrayList<Page>());
        replay(userService, pageLayoutRepository, pageRepository, pageTemplateRepository);

        Page newPage = pageService.addNewUserPage(PAGE_NAME, PAGE_LAYOUT_CODE);
View Full Code Here


        setHint(QueryHints.HINT_RESULT_COUNT, 1); // for DB2 optimization
    boolean queryFetchPlanUsed = pushQueryFetchPlan();
    try {
        List result = getResultList();
        if (result == null || result.isEmpty())
                throw new NoResultException(_loc.get("no-result", getQueryString())
                        .getMessage());
        if (result.size() > 1)
                throw new NonUniqueResultException(_loc.get("non-unique-result",
                        getQueryString(), result.size()).getMessage());
        try {
            return (X)result.get(0);
        } catch (Exception e) {
                throw new NoResultException(_loc.get("no-result", getQueryString())
                    .getMessage());
        }
    } finally {
      popQueryFetchPlan(queryFetchPlanUsed);
    }
View Full Code Here

    public Account getAccountByPassport(Passport passport) throws NoResultException {
        Account user = entityManager.find(Account.class, passport);
        if (user != null) {
            return user;
        } else {
            throw new NoResultException();
        }
    }
View Full Code Here

        setHint(QueryHints.HINT_RESULT_COUNT, 1); // for DB2 optimization
    boolean queryFetchPlanUsed = pushQueryFetchPlan();
    try {
        List result = getResultList();
        if (result == null || result.isEmpty())
                throw new NoResultException(_loc.get("no-result", getQueryString())
                        .getMessage());
        if (result.size() > 1)
                throw new NonUniqueResultException(_loc.get("non-unique-result",
                        getQueryString(), result.size()).getMessage());
        try {
            return (X)result.get(0);
        } catch (Exception e) {
                throw new NoResultException(_loc.get("no-result", getQueryString())
                    .getMessage());
        }
    } finally {
      popQueryFetchPlan(queryFetchPlanUsed);
    }
View Full Code Here

        expectedPage.setPageType(PageType.USER);

        expect(userService.getAuthenticatedUser()).andReturn(user);
        expect(pageLayoutRepository.getByPageLayoutCode(PAGE_LAYOUT_CODE)).andReturn(pageLayout);
        expect(pageRepository.save(expectedPage)).andReturn(expectedPage);
        expect(pageTemplateRepository.getDefaultPage(PageType.USER)).andThrow(new NoResultException("No Result Exception"));

        expect(pageRepository.getAllPages(user.getEntityId(), PageType.USER)).andReturn(new ArrayList<Page>());
        replay(userService, pageLayoutRepository, pageRepository, pageTemplateRepository);

        Page newPage = pageService.addNewUserPage(PAGE_NAME, PAGE_LAYOUT_CODE);
View Full Code Here

  public X getSingleResult() {
    _em.assertNotCloseInvoked();
        setHint("openjpa.hint.OptimizeResultCount", 1); // for DB2 optimization
    List result = getResultList();
    if (result == null || result.isEmpty())
            throw new NoResultException(_loc.get("no-result", getQueryString())
                    .getMessage());
    if (result.size() > 1)
            throw new NonUniqueResultException(_loc.get("non-unique-result",
                    getQueryString(), result.size()).getMessage());
    try {
        return (X)result.get(0);
    } catch (Exception e) {
            throw new NoResultException(_loc.get("no-result", getQueryString())
                .getMessage());
    }
  }
View Full Code Here

    private Section findSectionById(Long id) throws NoResultException
    {
        EntityManager em = emf.createEntityManager();
        Section section = em.find(Section.class, id);
        if (section == null)
            throw new NoResultException();
        em.close();
        return section;
    }
View Full Code Here

            {
                ji.setState(State.CANCELLED);
            }
            else
            {
                throw new NoResultException();
            }
            em.getTransaction().commit();
        }
        catch (NoResultException e)
        {
View Full Code Here

        {
            em.getTransaction().begin();
            ji = em.find(JobInstance.class, idJob, LockModeType.PESSIMISTIC_WRITE);
            if (!ji.getState().equals(State.SUBMITTED))
            {
                throw new NoResultException();
            }
            ji.setQueue(q);
            em.getTransaction().commit();
        }
        catch (NoResultException e)
View Full Code Here

        {
            em = getEm();
            h = em.find(History.class, jobId);
            if (h == null)
            {
                throw new NoResultException("No history for this jobId. perhaps the job isn't ended yet");
            }
        }
        catch (Exception e)
        {
            h = null;
View Full Code Here

TOP

Related Classes of javax.persistence.NoResultException

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.