Skip to content

Commit dc24b9b

Browse files
author
graeme
committed
fix for failing tests
git-svn-id: https://svn.codehaus.org/grails/trunk@6272 1cfb16fd-6d17-0410-8ff1-b7e8e1e2867d
1 parent 61a01f0 commit dc24b9b

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/persistence/grails/orm/HibernateCriteriaBuilder.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -678,16 +678,21 @@ private boolean validateSimpleExpression() {
678678

679679

680680
public Object invokeMethod(String name, Object obj) {
681-
Object[] args = obj.getClass().isArray() ? (Object[])obj : new Object[]{obj};
681+
Object[] args = obj.getClass().isArray() ? (Object[])obj : new Object[]{obj};
682+
if(this.criteria != null)
683+
this.criteriaMetaClass = GroovySystem.getMetaClassRegistry().getMetaClass(criteria.getClass());
684+
682685
if(name.equals(ROOT_CALL) ||
683686
name.equals(LIST_CALL) ||
684687
name.equals(LIST_DISTINCT_CALL) ||
685688
name.equals(GET_CALL) ||
686689
name.equals(COUNT_CALL) ||
687690
name.equals(SCROLL_CALL) && args.length == 1 && args[0] instanceof Closure) {
688691

689-
if(this.criteria != null)
692+
if(this.criteria != null) {
690693
throwRuntimeException( new IllegalArgumentException("call to [" + name + "] not supported here"));
694+
}
695+
691696

692697
if (name.equals(GET_CALL)) {
693698
this.uniqueResult = true;
@@ -699,7 +704,7 @@ else if (name.equals(COUNT_CALL)) {
699704
this.count = true;
700705
}
701706
else if (name.equals(LIST_DISTINCT_CALL)) {
702-
this.resultTransformer = CriteriaSpecification.DISTINCT_ROOT_ENTITY;
707+
this.resultTransformer = CriteriaSpecification.DISTINCT_ROOT_ENTITY;
703708
}
704709

705710
if(TransactionSynchronizationManager.hasResource(sessionFactory)) {
@@ -710,7 +715,6 @@ else if (name.equals(LIST_DISTINCT_CALL)) {
710715
this.session = sessionFactory.openSession();
711716
}
712717
this.criteria = this.session.createCriteria(targetClass);
713-
this.criteriaMetaClass = GroovySystem.getMetaClassRegistry().getMetaClass(criteria.getClass());
714718

715719
invokeClosureNode(args);
716720

0 commit comments

Comments
 (0)