Package javax.persistence

Examples of javax.persistence.NonUniqueResultException


        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" ) );
        }
        else {
          return uniqueResult.iterator().next();
        }
View Full Code Here


    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())
View Full Code Here

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

        if (result == null || result.size() == 0) {
            throw new NoResultException();
        }

        if (result.size() > 1) {
            throw new NonUniqueResultException();
        }

        return result.get(0);
    }
View Full Code Here

        try {
            return entityManager.createQuery(query, Reader.class).getSingleResult();
        } catch (NoResultException nre) {
            return null;
        } catch (NonUniqueResultException nure) {
            throw new NonUniqueResultException("There are more readers with this email: " + email);
        }
    }
View Full Code Here

    case 0:
      return null;
    case 1:
      return resultList.get(0);
    default:
      throw new NonUniqueResultException();
    }
  }
View Full Code Here

            break;
        case 1:
            ret = resultList.get(0);
            break;
        default:
            throw new NonUniqueResultException("Several entries with the same primary key where found in the table HardTokenPropertyData.");
        }

        return ret;
    }
View Full Code Here

    NoResultException noResult = new NoResultException();
    assertSame(EmptyResultDataAccessException.class,
        EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(noResult).getClass());

    NonUniqueResultException nonUniqueResult = new NonUniqueResultException();
    assertSame(IncorrectResultSizeDataAccessException.class,
        EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(nonUniqueResult).getClass());

    OptimisticLockException optimisticLock = new OptimisticLockException();
    assertSame(JpaOptimisticLockingFailureException.class,
View Full Code Here

        List<?> rows = getResultList();
        if (rows.size() == 0) {
            throw new NoResultException();
        }
        if (rows.size() > 1) {
            throw new NonUniqueResultException();
        }

        return rows.get(0);
    }
View Full Code Here

        {
            throw new NoResultException("No results for query: " + query.toString());
        }
        catch (QueryNotUniqueException ex)
        {
            throw new NonUniqueResultException("Expected a single result for query: " + query.toString() +
                " : " + StringUtils.getStringFromStackTrace(ex));
        }
        catch (QueryInvalidParametersException ex)
        {
            throw new IllegalArgumentException(ex.getMessage(),ex);
View Full Code Here

TOP

Related Classes of javax.persistence.NonUniqueResultException

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.