List of usage examples for javax.persistence NonUniqueResultException initCause
public synchronized Throwable initCause(Throwable cause)
From source file:org.sonar.jpa.session.JpaDatabaseSession.java
/** * @return the result or <code>null</code>, if not found * @throws NonUniqueResultException if more than one result *///from w ww.j av a 2s .co m @Override public <T> T getSingleResult(Class<T> entityClass, Object... criterias) { try { return getSingleResult(getQueryForCriterias(entityClass, true, criterias), (T) null); } catch (NonUniqueResultException ex) { NonUniqueResultException e = new NonUniqueResultException("Expected single result for entitiy " + entityClass.getSimpleName() + " with criterias : " + StringUtils.join(criterias, ",")); throw (NonUniqueResultException) e.initCause(ex); } }