Created
November 20, 2014 17:40
-
-
Save johnrengelman/9be4218223ff34ca627c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package foo | |
class Bar { | |
String name | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package foo | |
class Foo { | |
Bar bar | |
static constraints = { | |
bar nullable: true | |
} | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package foo | |
class FooIntTest extends GroovyTestCase { | |
FooService fooService | |
void testList() { | |
Bar bar = new Bar(name: 'first').save() | |
Bar bar2 = new Bar(name: 'second').save() | |
Foo foo = new Foo(bar: bar).save() | |
Foo foo2 = new Foo(bar: bar2).save() | |
Foo foo3 = new Foo(bar: null).save() | |
List<Foo> foos = fooService.list() | |
assert foos.size() == 1 | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package foo | |
class FooService { | |
List<Foo> list() { | |
Foo.where { | |
bar?.name == 'first' | |
}.list() | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Failure: testList(foo.FooIntTest) | |
| org.hibernate.QueryException: could not resolve property: name of: foo.Foo | |
at grails.gorm.DetachedCriteria$_list_closure3.doCall(DetachedCriteria.groovy:847) | |
at grails.gorm.DetachedCriteria$_withPopulatedQuery_closure10.doCall(DetachedCriteria.groovy:1213) | |
at org.grails.datastore.gorm.GormStaticApi$_withDatastoreSession_closure23.doCall(GormStaticApi.groovy:700) | |
at org.grails.datastore.mapping.core.DatastoreUtils.execute(DatastoreUtils.java:302) | |
at org.grails.datastore.gorm.AbstractDatastoreApi.execute(AbstractDatastoreApi.groovy:37) | |
at org.grails.datastore.gorm.GormStaticApi.withDatastoreSession(GormStaticApi.groovy:699) | |
at grails.gorm.DetachedCriteria.withPopulatedQuery(DetachedCriteria.groovy:1184) | |
at grails.gorm.DetachedCriteria.list(DetachedCriteria.groovy:843) | |
at grails.gorm.DetachedCriteria.list(DetachedCriteria.groovy:842) | |
at foo.FooService.list(FooService.groovy:6) | |
at foo.FooIntTest.testList(FooIntTest.groovy:15) | |
at junit.framework.TestCase.runTest(TestCase.java:176) | |
at junit.framework.TestCase.runBare(TestCase.java:141) | |
at junit.framework.TestResult$1.protect(TestResult.java:122) | |
at junit.framework.TestResult.runProtected(TestResult.java:142) | |
at junit.framework.TestResult.run(TestResult.java:125) | |
at junit.framework.TestCase.run(TestCase.java:129) | |
at junit.framework.TestSuite.runTest(TestSuite.java:255) | |
at junit.framework.TestSuite.run(TestSuite.java:250) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment