How to do safe inserts using GORM for Mongo's low-level API?
This appears due to the GMongo library and how it patches the DBCollection
object to handle passing of Map
objects to the insert
method and converts them. It assumes that all of the arguments of the insert
method are Map
objects and will then try to get the value
property from the Map.Entry
.
Looking at the source of Patcher.groovy from GMongo library you'll see the function _convert()
that attempts to do this. It looks like a fork of the Github project with type check on the argument (either to see if it's a WriteConcern
or to check if it's actually a Map
before passing to the _converAllCharSeqToString
) is necessary.
EDIT:
I created a pull request on Github for the appropriate code change, but as with all things Groovy, patching the class can also help. You can "patch" the WriteConcern
class in your BootStrap.groovy
to have a getValue
method and that will allow you to pass the parameter in:
def init = { servletContext -> com.mongodb.WriteConcern.metaClass.getValue = { null }}