Package javax.persistence

Examples of javax.persistence.NoResultException


  @SuppressWarnings( { "ThrowableInstanceNeverThrown" } )
  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


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

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

  @SuppressWarnings( { "ThrowableInstanceNeverThrown", "unchecked" })
  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

    }

    @Test(expected = AuthenticationException.class)
    public void anInvalidUserShouldntBeAbleToConnect() {
        // Given
        given(userDao.findByUsername(AN_INVALID_USER)).willThrow(new NoResultException());

        // When
        authenticator.authenticateCredentials(AN_INVALID_USER, AN_INVALID_PASSWORD);

        // Then
View Full Code Here

  public void testConvertJpaPersistenceException() {
    EntityNotFoundException entityNotFound = new EntityNotFoundException();
    assertSame(JpaObjectRetrievalFailureException.class,
        EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(entityNotFound).getClass());

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

    NonUniqueResultException nonUniqueResult = new NonUniqueResultException();
    assertSame(IncorrectResultSizeDataAccessException.class,
View Full Code Here

  public X getSingleResult() {
    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

  @SuppressWarnings({ "ThrowableInstanceNeverThrown" })
  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

    public Object getSingleResult() throws AuditException, NonUniqueResultException, NoResultException {
        List result = list();

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

        if (result.size() > 1) {
            throw new NonUniqueResultException();
        }
View Full Code Here

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

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

  @SuppressWarnings( { "ThrowableInstanceNeverThrown" } )
  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

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.