Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 2.0 final
-
Fix Version/s: 2.0.1
-
Component/s: Persistence
-
Labels:
-
Environment:Win7 x64, jdk 1.6.0_25
-
Testcase included:yes
Description
Assume domain class with parametrized named query, e.g.:
class Book {
Integer year
static namedQueries = {
ofYear { Integer year ->
if (year) eq 'year', year
}
}
}
The following call:
Book.ofYear(2012).ofYear(null).list()
throws the NPE:
java.lang.NullPointerException at org.grails.datastore.gorm.query.NamedCriteriaProxy.getPreparedCriteriaClosure(NamedQueriesBuilder.groovy:212) at org.grails.datastore.gorm.query.NamedCriteriaProxy.invokeCriteriaClosure(NamedQueriesBuilder.groovy:77) at org.grails.datastore.gorm.query.NamedCriteriaProxy$_listInternal_closure1.doCall(NamedQueriesBuilder.groovy:85) at grails.gorm.CriteriaBuilder.invokeClosureNode(CriteriaBuilder.java:976) at grails.gorm.CriteriaBuilder.invokeMethod(CriteriaBuilder.java:301) at org.grails.datastore.gorm.GormStaticApi.withCriteria(GormStaticApi.groovy:261) at org.grails.datastore.gorm.query.NamedCriteriaProxy.listInternal(NamedQueriesBuilder.groovy:100) at org.grails.datastore.gorm.query.NamedCriteriaProxy.list(NamedQueriesBuilder.groovy:104) ...
Check unit test for cases when null parameter works.
Attachments
Activity
- All
- Comments
- Work Log
- History
- Activity
- Git Commits
This should be resolved as soon as we upgrade to Groovy 1.8.6. When we do that we should uncomment NamedCriteriaTests.testPassingNullToAChainedNamedQuery.