Details
Description
belongsTo operation is broken for MongoDB and this is seen in show.gsp generated by scaffolding. Works for hibernate.
This is a regression with respect to 2.0.0.M1.
Steps to reproduce the problem.
1. Have these 2 domain classes:
package someapp class Sample { static mapWith="mongo" static hasMany = [sampleStrings:SampleString] String name } package someapp class SampleString { static mapWith = "mongo" String name static belongsTo = [sample:Sample] }
2. Generate all for the above 2 classes and run the app.
generate-all someapp.Sample
generate-all someapp.SampleString
run-app someapp
3. In the browser, go to http://localhost:8080/someApp/sample/create and create an instance of Sample. Once the sample is created and we are redirected to show,http://localhost:8080/someApp/sample/show/1, we hit this error:
Line | Method ->> 55 | runTask in \grails-app\views\sample\show.gsp - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Caused by InvokerInvocationException: java.lang.NoSuchMethodError: org.grails.datastore.mapping.query.Query$ProjectionList.id()Lorg/grails/datastore/mapping/query/Query$ProjectionList; ->> 95 | run in C__Users_SomeUser_Documents_NetBeansProjects_someApp_grails_app_views_sample_show_gsp - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | 886 | runTask in java.util.concurrent.ThreadPoolExecutor$Worker | 908 | run . . in '' ^ 662 | run in java.lang.Thread Caused by NoSuchMethodError: org.grails.datastore.mapping.query.Query$ProjectionList.id()Lorg/grails/datastore/mapping/query/Query$ProjectionList; ->> 592 | query in org.grails.datastore.mapping.mongo.engine.MongoEntityPersister$MongoAssociationIndexer - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | 199 | initialize in org.grails.datastore.mapping.collection.AbstractPersistentCollection | 87 | isEmpty in '' | 65 | doCall in C__Users_SomeUser_Documents_NetBeansProjects_someApp_grails_app_views_sample_show_gsp$_run_closure2 | 95 | run . . in C__Users_SomeUser_Documents_NetBeansProjects_someApp_grails_app_views_sample_show_gsp | 886 | runTask in java.util.concurrent.ThreadPoolExecutor$Worker | 908 | run . . in '' ^ 662 | run in java.lang.Thread
The exception above is raised by the g:if condition given below in show.gsp
<g:if test="${sampleInstance?.sampleStrings}"> <li class="fieldcontain"> <span id="sampleStrings-label" class="property-label"><g:message code="sample.sampleStrings.label" default="Sample Strings" /></span> <g:each in="${sampleInstance.sampleStrings}" var="s"> <span class="property-value" aria-labelledby="sampleStrings-label"><g:link controller="sampleString" action="show" id="${s.id}">${s?.encodeAsHTML()}</g:link></span> </g:each> </li> </g:if>
Activity
- All
- Comments
- Work Log
- History
- Activity
- Git Commits
I can't reproduce this issue with Grails 2.0.3 and MongoDB 1.0.0.GA. The issue must have been fixed already. So, closing this issue. Please create a new JIRA if you face any issues with the 1.0 GA release. Thanks, Bobby