Skip to content

Commit

Permalink
fix for failing tests
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.codehaus.org/grails/trunk@6272 1cfb16fd-6d17-0410-8ff1-b7e8e1e2867d
  • Loading branch information
graeme committed Dec 7, 2007
1 parent 61a01f0 commit dc24b9b
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/persistence/grails/orm/HibernateCriteriaBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -678,16 +678,21 @@ private boolean validateSimpleExpression() {


public Object invokeMethod(String name, Object obj) {
Object[] args = obj.getClass().isArray() ? (Object[])obj : new Object[]{obj};
Object[] args = obj.getClass().isArray() ? (Object[])obj : new Object[]{obj};
if(this.criteria != null)
this.criteriaMetaClass = GroovySystem.getMetaClassRegistry().getMetaClass(criteria.getClass());

if(name.equals(ROOT_CALL) ||
name.equals(LIST_CALL) ||
name.equals(LIST_DISTINCT_CALL) ||
name.equals(GET_CALL) ||
name.equals(COUNT_CALL) ||
name.equals(SCROLL_CALL) && args.length == 1 && args[0] instanceof Closure) {

if(this.criteria != null)
if(this.criteria != null) {
throwRuntimeException( new IllegalArgumentException("call to [" + name + "] not supported here"));
}


if (name.equals(GET_CALL)) {
this.uniqueResult = true;
Expand All @@ -699,7 +704,7 @@ else if (name.equals(COUNT_CALL)) {
this.count = true;
}
else if (name.equals(LIST_DISTINCT_CALL)) {
this.resultTransformer = CriteriaSpecification.DISTINCT_ROOT_ENTITY;
this.resultTransformer = CriteriaSpecification.DISTINCT_ROOT_ENTITY;
}

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

invokeClosureNode(args);

Expand Down

0 comments on commit dc24b9b

Please sign in to comment.