try {
return (T) criteria.getClass().getMethod(methodName, new Class[0])
.invoke(criteria, new Object[0]);
} catch (final Exception e) {
if (e.getCause() instanceof NonUniqueResultException) {
throw new JournalException(e.getCause().getMessage(), e.getCause()); // NOPMD by r39 on 3/30/11 12:07 PM
} else if (e.getCause() instanceof QueryException) {
throw JournalException.wrapperException(new IllegalArgumentException(Messages.Error.IAE_INVALID_PROP
+ param.keySet(), e
.getCause()));
} else if (e.getCause() instanceof ClassCastException) {
throw new IllegalArgumentException(Messages.Error.IAE_TYPE_MISMATCH, e.getCause()); // NOPMD by r39 on 3/30/11 12:07 PM
} else {
if (InvocationTargetException.class.equals(e.getClass())) {
final InvocationTargetException ite = (InvocationTargetException) e;
final String errorMessage = ite.getTargetException().getMessage();
throw new JournalException(errorMessage, ite);//NOPMD we want to wrap original stack trace.
} else {
throw new JournalException(Messages.Error.SYSTEM_ERROR, e);
}
}
}
}