Search in sources :

Example 16 with NonUniqueResultException

use of javax.persistence.NonUniqueResultException in project Asqatasun by Asqatasun.

the class OptionElementDAOImpl method findOptionElementFromUserAndFamilyCode.

@Override
public Collection<OptionElement> findOptionElementFromUserAndFamilyCode(User user, String optionFamilyCode) {
    Query query = entityManager.createQuery("SELECT distinct(u.optionElementSet) FROM " + getUserEntityClass().getName() + " u" + " LEFT JOIN u.optionElementSet oe" + " WHERE u=:user" + " AND oe.option.optionFamily.code=:optionFamilyCode");
    query.setParameter("user", user);
    query.setParameter("optionFamilyCode", optionFamilyCode);
    try {
        return (Collection<OptionElement>) query.getResultList();
    } catch (NoResultException | NonUniqueResultException nre) {
        return null;
    }
}
Also used : NonUniqueResultException(javax.persistence.NonUniqueResultException) Query(javax.persistence.Query) Collection(java.util.Collection) NoResultException(javax.persistence.NoResultException)

Aggregations

NoResultException (javax.persistence.NoResultException)16 NonUniqueResultException (javax.persistence.NonUniqueResultException)16 Query (javax.persistence.Query)14 List (java.util.List)3 WebResource (org.asqatasun.entity.subject.WebResource)3 Collection (java.util.Collection)2 EntityExistsException (javax.persistence.EntityExistsException)2 EntityNotFoundException (javax.persistence.EntityNotFoundException)2 OptimisticLockException (javax.persistence.OptimisticLockException)2 PersistenceException (javax.persistence.PersistenceException)2 SQLException (java.sql.SQLException)1 LockTimeoutException (javax.persistence.LockTimeoutException)1 PessimisticLockException (javax.persistence.PessimisticLockException)1 QueryTimeoutException (javax.persistence.QueryTimeoutException)1 RollbackException (javax.persistence.RollbackException)1 TransactionRequiredException (javax.persistence.TransactionRequiredException)1 Parameter (org.asqatasun.entity.parameterization.Parameter)1 ParameterElement (org.asqatasun.entity.parameterization.ParameterElement)1 ParameterFamily (org.asqatasun.entity.parameterization.ParameterFamily)1 PageImpl (org.asqatasun.entity.subject.PageImpl)1