use of javax.persistence.NonUniqueResultException in project Asqatasun by Asqatasun.
the class OptionElementDAO method findOptionElementFromUserAndFamilyCode.
public Collection<OptionElementImpl> 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<OptionElementImpl>) query.getResultList();
} catch (NoResultException | NonUniqueResultException nre) {
return null;
}
}
use of javax.persistence.NonUniqueResultException in project Asqatasun by Asqatasun.
the class OptionElementDAO method findOptionElementFromUser.
public Collection<OptionElementImpl> findOptionElementFromUser(User user) {
Query query = entityManager.createQuery("SELECT u.optionElementSet FROM " + getUserEntityClass().getName() + " u" + " WHERE u=:user");
query.setParameter("user", user);
try {
return (Collection<OptionElementImpl>) query.getResultList();
} catch (NoResultException | NonUniqueResultException nre) {
return null;
}
}
use of javax.persistence.NonUniqueResultException in project Asqatasun by Asqatasun.
the class ParameterFamilyDAOImpl method findParameterFamilyFromCode.
@Override
public ParameterFamily findParameterFamilyFromCode(String parameterFamilyCode) {
Query query = entityManager.createQuery("SELECT pf FROM " + getEntityClass().getName() + " pf" + " WHERE pf.paramFamilyCode = :parameterFamilyCode");
query.setParameter("parameterFamilyCode", parameterFamilyCode);
try {
return (ParameterFamily) query.getSingleResult();
} catch (NoResultException nre) {
return null;
} catch (NonUniqueResultException nure) {
return null;
}
}
use of javax.persistence.NonUniqueResultException in project Asqatasun by Asqatasun.
the class ContentDAOImpl method find.
@Override
public Content find(Audit audit, String uri) {
Query query = entityManager.createQuery("SELECT c FROM " + getEntityClass().getName() + " c" + " WHERE c.audit = :audit" + " AND c.uri = :uri" + " AND c.httpStatusCode =:httpStatusCode");
query.setParameter(AUDIT_KEY, audit);
query.setParameter("uri", uri);
query.setParameter(HTTP_STATUS_CODE_KEY, HTTP_STATUS_OK);
try {
return (Content) query.getSingleResult();
} catch (NoResultException nre) {
return null;
} catch (NonUniqueResultException nure) {
List<Content> queryResult = query.getResultList();
for (Content content : queryResult) {
if (StringUtils.equals(content.getURI(), uri)) {
return content;
}
}
return null;
}
}
use of javax.persistence.NonUniqueResultException in project Asqatasun by Asqatasun.
the class OptionElementDAO method findOptionElementFromValueAndOption.
/**
* @param value
* @param option
* @return
*/
public OptionElementImpl findOptionElementFromValueAndOption(String value, Option option) {
Query query = entityManager.createQuery("SELECT oe FROM " + getEntityClass().getName() + " oe" + " WHERE oe.value=:value" + " AND oe.option=:option");
query.setParameter("value", value);
query.setParameter("option", option);
try {
return (OptionElementImpl) query.getSingleResult();
} catch (NoResultException | NonUniqueResultException nre) {
return null;
}
}
Aggregations