List of usage examples for javax.persistence NonUniqueResultException NonUniqueResultException
public NonUniqueResultException()
NonUniqueResultException
exception with null
as its detail message. From source file:org.jnap.core.persistence.jpa.DaoSupport.java
/** * /* w w w. j a v a2 s . c o m*/ * @param result * @return * @throws QueryException */ protected E handleUniqueResult(List<E> result) throws PersistenceException { E uniqueResult = null; if (result != null && result.size() > 0) { if (result.size() == 1) { uniqueResult = result.get(0); } else { throw new NonUniqueResultException(); //TODO } } return uniqueResult; }
From source file:org.batoo.jpa.core.impl.criteria.QueryImpl.java
/** * {@inheritDoc}//from w w w.j ava2s . c om * */ @Override public X getSingleResult() { final List<X> resultList = this.getResultList(); if (resultList.size() > 1) { throw new NonUniqueResultException(); } if (resultList.size() == 0) { throw new NoResultException(); } return resultList.get(0); }
From source file:org.batoo.jpa.core.impl.nativeQuery.NativeQuery.java
/** * {@inheritDoc}// ww w . j a v a 2 s .c o m * */ @Override public Object getSingleResult() { final List<?> resultList = this.getResultList(); if (resultList.size() > 1) { throw new NonUniqueResultException(); } if (resultList.size() == 0) { throw new NoResultException(); } return resultList.get(0); }