Package javax.persistence

Examples of javax.persistence.NoResultException


    protected void setRollbackOnly() {
        entityManager.setRollbackOnly();
    }

    protected void throwNoResultException(String message) {
        throw new NoResultException(message);
    }
View Full Code Here


    @Override
    public void removeNote(Long noteId)
    {
        final Note note = entityManager.find(Note.class, noteId);
        if (null == note) {
            throw new NoResultException("No note with id " + noteId + " found");
        }
        entityManager.remove(note);
    }
View Full Code Here

      } else {
        Integer groupId = getCurrentSnapshotGroupId();
        if (groupId != null) {
          snapshotGroup = manager.find(SnapshotGroup.class, groupId);
          if (snapshotGroup == null) {
            throw new NoResultException();
          }
        } else {
          SnapshotGroupService service = new SnapshotGroupService(manager);
          MavenProject parent = sonarProject.getParent();
          int maxDept = 100;
View Full Code Here

      } else {
        Integer groupId = getCurrentSnapshotGroupId();
        if (groupId != null) {
          snapshotGroup = manager.find(SnapshotGroup.class, groupId);
          if (snapshotGroup == null) {
            throw new NoResultException();
          }
        } else {
          SnapshotGroupService service = new SnapshotGroupService(manager);
          MavenProject parent = sonarProject.getParent();
          int maxDept = 100;
View Full Code Here

 
  public SnapshotGroup getLastUnprocessedGroup(Integer projectId, long delayInMs, long roofTime ) throws NoResultException {
    Query query = manager.createNamedQuery( SnapshotGroup.SQL_SELECT_LAST_UNPROCESSED );
    query.setParameter("idProject", projectId);
    List snapshot = query.getResultList();
    if ( snapshot.size() == 0 ) throw new NoResultException();
    roofTime = roofTime + delayInMs;
    for (Object aSnapshot : snapshot) {
      SnapshotGroup grp = (SnapshotGroup) aSnapshot;
      if ( grp.getCreatedAt().getTime() < roofTime ) {
        return grp;
      }
    }
    throw new NoResultException();
  }
View Full Code Here

  public SnapshotGroup getLastUnprocessedGroup(Integer projectId, long delayInMs, long roofTime ) throws NoResultException {
    Query query = manager.createNamedQuery( SnapshotGroup.SQL_SELECT_LAST_UNPROCESSED );
    query.setParameter("idProject", projectId);
    List snapshot = query.getResultList();
    if (snapshot.isEmpty()) {
      throw new NoResultException();
    }
    roofTime += delayInMs;
    for (Object aSnapshot : snapshot) {
      SnapshotGroup grp = (SnapshotGroup) aSnapshot;
      if ( grp.getCreatedAt().getTime() < roofTime ) {
        return grp;
      }
    }
    throw new NoResultException();
  }
View Full Code Here

    protected void setRollbackOnly() {
        entityManager.setRollbackOnly();
    }

    protected void throwNoResultException(String message) {
        throw new NoResultException(message);
    }
View Full Code Here

  public Object getSingleResult() {
    try {
      List result = query.list();
      if ( result.size() == 0 ) {
        throwPersistenceException( new NoResultException( "No entity found for query" ) );
      }
      else if ( result.size() > 1 ) {
        Set uniqueResult = new HashSet(result);
        if ( uniqueResult.size() > 1 ) {
          throwPersistenceException( new NonUniqueResultException( "result returns " + uniqueResult.size() + " elements") );
View Full Code Here

  @Override
  public Object getSingleResult() {
    final List resultList = getResultList();
    if ( resultList == null || resultList.isEmpty() ) {
      throw new NoResultException(
          String.format(
              "Call to stored procedure [%s] returned no results",
              procedureCall.getProcedureName()
          )
      );
View Full Code Here

    beforeQuery();
    try {
      final List<X> result = query.list();

      if ( result.size() == 0 ) {
        NoResultException nre = new NoResultException( "No entity found for query" );
        getEntityManager().handlePersistenceException( nre );
        throw nre;
      }
      else if ( result.size() > 1 ) {
        final Set<X> uniqueResult = new HashSet<X>(result);
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.