use of javax.persistence.NonUniqueResultException in project Asqatasun by Asqatasun.
the class ContentDAOImpl method find.
@Override
public Content find(WebResource page, String uri) {
Query query = entityManager.createQuery("SELECT c FROM " + getEntityClass().getName() + " c" + " WHERE c.page = :page " + " AND c.uri = :uri");
query.setParameter("page", page);
query.setParameter("uri", uri);
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 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 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 WebResourceDAOImpl method findByUrlAndParentWebResource.
@Override
public WebResource findByUrlAndParentWebResource(String url, WebResource webResource) {
Query query = entityManager.createQuery("SELECT wr FROM " + PageImpl.class.getName() + " wr" + " WHERE wr.url = :url" + " AND wr.parent =:webResource");
query.setParameter("url", url);
query.setParameter("webResource", webResource);
try {
return (WebResource) query.getSingleResult();
} catch (NoResultException nre) {
return null;
} catch (NonUniqueResultException nure) {
List<WebResource> queryResult = query.getResultList();
for (WebResource wr : queryResult) {
if (StringUtils.equals(wr.getURL(), url)) {
return wr;
}
}
return null;
}
}
use of javax.persistence.NonUniqueResultException in project Asqatasun by Asqatasun.
the class OptionDAOImpl method findOptionFromCode.
@Override
public Option findOptionFromCode(String optionCode) {
Query query = entityManager.createQuery("SELECT o FROM " + getEntityClass().getName() + " o" + " WHERE o.code = :optionCode");
query.setParameter("optionCode", optionCode);
try {
return (Option) query.getSingleResult();
} catch (NoResultException nre) {
return null;
} catch (NonUniqueResultException nure) {
return null;
}
}
Aggregations