Package com.tll.dao

Examples of com.tll.dao.EntityNotFoundException


  @Override
  public <E extends IEntity> E findEntity(Criteria<E> criteria) throws InvalidCriteriaException,
      EntityNotFoundException, NonUniqueResultException, DataAccessException {
    final List<E> list = findEntities(criteria, null);
    if(list == null || list.size() < 1) {
      throw new EntityNotFoundException("No matching entity found.");
    }
    else if(list.size() > 1) {
      throw new NonUniqueResultException("More than one matching entity found.");
    }
    assert list.size() == 1;
View Full Code Here


      DataAccessException {
    final List<E> list = getDb4oTemplate().query(p);
    if(list == null || list.size() < 1) {
      final String msg = "No matching entity found for key: [" + key + ']';
      logger.debug(msg);
      throw new EntityNotFoundException(msg);
    }
    if(list.size() > 1) {
      final String msg = list.size() + " matching entities found (not one) for key: [" + key + ']';
      logger.debug(msg);
      throw new EntityNotFoundException(msg);
    }
    assert list.size() == 1;
    return list.get(0);
  }
View Full Code Here

  @Override
  public <E extends IEntity> void purge(Class<E> entityType, Long pk) throws EntityNotFoundException,
      DataAccessException {
    final E existing = load(entityType, pk);
    if(existing == null) throw new EntityNotFoundException("Entity of primary key: " + pk + " not found for purging");
    getDb4oTemplate().delete(existing);
    getDb4oTemplate().purge(existing);
  }
View Full Code Here

    }
    catch(final InvalidCriteriaException e) {
      throw new IllegalArgumentException("Unexpected invalid criteria exception occurred");
    }
    if(user == null) {
      throw new EntityNotFoundException("User with username: " + emailAddress + " was not found.");
    }
    final Account ua = user.getAccount();
    user.setAccount(ua);
    return user;
  }
View Full Code Here

  }

  @Transactional
  private User getUserById(long userId) throws EntityNotFoundException {
    final User user = dao.load(User.class, Long.valueOf(userId));
    if(user == null) throw new EntityNotFoundException("User of id '" + userId + "' not found");
    return user;
  }
View Full Code Here

  @Override
  public <E extends IEntity> E findEntity(Criteria<E> criteria) throws InvalidCriteriaException,
  EntityNotFoundException, NonUniqueResultException, DataAccessException {
    final List<E> list = findEntities(criteria, null);
    if(list == null || list.size() < 1) {
      throw new EntityNotFoundException("No matching entity found.");
    }
    else if(list.size() > 1) {
      throw new NonUniqueResultException("More than one matching entity found.");
    }
    assert list.size() == 1;
View Full Code Here

  private <E extends IEntity> E loadByPredicate(Predicate<E> p, IKey<E> key) throws EntityNotFoundException, DataAccessException {
    final List<E> list = getDb4oTemplate().query(p);
    if(list == null || list.size() < 1) {
      final String msg = "No matching entity found for key: [" + key +  ']';
      log.debug(msg);
      throw new EntityNotFoundException(msg);
    }
    if(list.size() > 1) {
      final String msg = list.size() + " matching entities found (not one) for key: [" + key + ']';
      log.debug(msg);
      throw new EntityNotFoundException(msg);
    }
    assert list.size() == 1;
    return list.get(0);
  }
View Full Code Here

  }

  @Override
  public <E extends IEntity> void purge(PrimaryKey<E> key) throws EntityNotFoundException, DataAccessException {
    final E existing = load(key);
    if(existing == null) throw new EntityNotFoundException("Entity of primary key: " + key + " not found for purging");
    getDb4oTemplate().delete(existing);
    getDb4oTemplate().purge(existing);
  }
View Full Code Here

    }
    catch(final InvalidCriteriaException e) {
      throw new IllegalArgumentException("Unexpected invalid criteria exception occurred");
    }
    if(user == null) {
      throw new EntityNotFoundException("User with username: " + emailAddress + " was not found.");
    }
    final Account ua = user.getAccount();
    user.setAccount(ua);
    return user;
  }
View Full Code Here

    updateSecurityContextIfNecessary(user.getUsername(), null, null, true);
  }

  private User getUserById(String userId) throws EntityNotFoundException {
    final User user = dao.load(new PrimaryKey<User>(User.class, userId));
    if(user == null) throw new EntityNotFoundException("User of id '" + userId + "' not found");
    return user;
  }
View Full Code Here

TOP

Related Classes of com.tll.dao.EntityNotFoundException

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.