Thank you for the update. I am noticing some issues with dynamic finders and having an attribute mapped to 'id'. Using findByStatusId results in the document not being found. So I attempted using findByText and I can see that it is trying to load '_id' into the statusId property. Since I still insert into the database using the mongo driver, I can work around this by mapping id to something else, but I figured I'd pass it along.
collection 'twitter.status'
createdAt attribute:'created_at'
statusId attribute:'id'
}
static constraints = {
}
}
//////////////////////////////////////////////////
def s = new Status(
createdAt: new Date(),
statusId: 10L,
text: "hi",
).save(flush:true)
def s = Status.findByStatusId(10L)
render s.text
2011-02-11 23:29:26,725 [http-8080-1] ERROR errors.GrailsExceptionResolver - Exception occurred when processing request: [GET] /hashchan/status/load
Stacktrace follows:
java.lang.NullPointerException: Cannot get property 'text' on null object
at hashchan.twitter.StatusController$_closure3.doCall(StatusController.groovy:19)
at hashchan.twitter.StatusController$_closure3.doCall(StatusController.groovy)
at java.lang.Thread.run(Thread.java:636)
def s = Status.findByText("hi")
2011-02-11 23:29:28,724 [http-8080-1] ERROR errors.GrailsExceptionResolver - Exception occurred when processing request: [GET] /hashchan/status/load
Stacktrace follows:
java.lang.IllegalArgumentException: Cannot convert value of type [org.bson.types.ObjectId] to required type [java.lang.Long] for property 'statusId': PropertyEditor [org.springframework.beans.propertyeditors.CustomNumberEditor] returned inappropriate value
at org.grails.datastore.gorm.finders.FindByFinder.invokeQuery(FindByFinder.java:53)
at org.grails.datastore.gorm.finders.FindByFinder.doInvokeInternal(FindByFinder.java:46)
at org.grails.datastore.gorm.finders.DynamicFinder.invoke(DynamicFinder.java:72)
at org.grails.datastore.gorm.finders.DynamicFinder.invoke(DynamicFinder.java:183)
at org.grails.datastore.gorm.GormEnhancer$_enhance_closure2.doCall(GormEnhancer.groovy:171)
at hashchan.twitter.StatusController$_closure3.doCall(StatusController.groovy:19)
at hashchan.twitter.StatusController$_closure3.doCall(StatusController.groovy)
at java.lang.Thread.run(Thread.java:636)