</BUG>
}
});
<BUG>}
protected Object getResult(Criteria crit) {
final List<?> list = crit.list();</BUG>
if (!list.isEmpty()) {
<BUG>return GrailsHibernateUtil.unwrapIfProxy(list.get(0));
}</BUG>
return null;

@Override
protected Object doInvokeInternalWithExpressions(final Class clazz, String methodName, final Object[] arguments, final List expressions, String operatorInUse, final DetachedCriteria detachedCriteria, final Closure additionalCriteria) {
final String operator = OPERATOR_OR.equals(operatorInUse) ? OPERATOR_OR : OPERATOR_AND;
return getHibernateTemplate().execute(new HibernateCallback<Object>() {
public Object doInHibernate(Session session) throws HibernateException, SQLException {
Criteria crit = buildCriteria(session, detachedCriteria, additionalCriteria, clazz, arguments, operator, expressions);
boolean useLimit = establishWhetherToUseLimit(clazz);
return getResult(crit, useLimit);
}
});
