Quantcast

Using findAndModify with GMongo

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Using findAndModify with GMongo

Ronny Løvtangen
I'm trying to make an auto incrementing field in MongoDB as described here: http://www.mongodb.org/display/DOCS/How+to+Make+an+Auto+Incrementing+Field

Here's my field:

> db.counters.find()
{ "_id" : "entryId", "c" : 1 }



I tried to use findAndModify from GMongo like this:

def counter = db.counters.findAndModify([_id: "entryId"], [$inc: ['c':1]])

which gives me the exception:

groovy.lang.MissingMethodException: No signature of method: com.mongodb.DBApiLayer$MyCollection.findAndModify() is applicable for argument types: (java.util.LinkedHashMap, java.util.LinkedHashMap) values: [[_id:entryId], [$inc:[c:1]]]
Possible solutions: findAndModify(com.mongodb.DBObject, com.mongodb.DBObject), findAndModify(com.mongodb.DBObject, com.mongodb.DBObject, com.mongodb.DBObject)
        at com.gmongo.internal.Patcher$__patchInternal_closure1.doCall(Patcher.groovy:41)
        at no.nsb.rapp.client.ClientReportController$_closure4.doCall(ClientReportController.groovy:90)
        at no.nsb.rapp.client.ClientReportController$_closure4.doCall(ClientReportController.groovy)
        at grails.plugin.springcache.web.GrailsFragmentCachingFilter.doFilter(GrailsFragmentCachingFilter.groovy:66)
        at net.sf.ehcache.constructs.web.filter.Filter.doFilter(Filter.java:86)
        at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:157)
        at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:131)
        at java.lang.Thread.run(Thread.java:680)


Using exactly the same parameters to 'update' works fine:

db.counters.update([_id: "entryId"], [$inc: ['c':1]])

and it looks to me that the signature of 'findAndModify' is equal to the signature of 'update':

   public com.mongodb.WriteResult update(com.mongodb.DBObject q, com.mongodb.DBObject o) throws com.mongodb.MongoException
   public com.mongodb.DBObject findAndModify(com.mongodb.DBObject query, com.mongodb.DBObject update)


I also tried adding 'as BasicDBObject' to the parameters, like on this blog: http://jameswilliams.be/blog/entry/165
But to no success

Do anyone have a solution to this?

Thanks,
Ronny Løvtangen




---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Using findAndModify with GMongo

Graeme Rocher-4
This isn't really a Groovy question and is more appropriate for the
MongoDB mailing list since it relates to use of the MongoDB Java
driver.

Anyway looking at the javadoc

http://api.mongodb.org/java/2.6.5/com/mongodb/DBCollection.html#findAndModify(com.mongodb.DBObject,
com.mongodb.DBObject)

findAndModify takes 2 DBObject parameters not maps

Cheers

On Wed, Oct 5, 2011 at 8:11 AM, Ronny Løvtangen <[hidden email]> wrote:

> I'm trying to make an auto incrementing field in MongoDB as described here: http://www.mongodb.org/display/DOCS/How+to+Make+an+Auto+Incrementing+Field
>
> Here's my field:
>
>> db.counters.find()
> { "_id" : "entryId", "c" : 1 }
>
>
>
> I tried to use findAndModify from GMongo like this:
>
> def counter = db.counters.findAndModify([_id: "entryId"], [$inc: ['c':1]])
>
> which gives me the exception:
>
> groovy.lang.MissingMethodException: No signature of method: com.mongodb.DBApiLayer$MyCollection.findAndModify() is applicable for argument types: (java.util.LinkedHashMap, java.util.LinkedHashMap) values: [[_id:entryId], [$inc:[c:1]]]
> Possible solutions: findAndModify(com.mongodb.DBObject, com.mongodb.DBObject), findAndModify(com.mongodb.DBObject, com.mongodb.DBObject, com.mongodb.DBObject)
>        at com.gmongo.internal.Patcher$__patchInternal_closure1.doCall(Patcher.groovy:41)
>        at no.nsb.rapp.client.ClientReportController$_closure4.doCall(ClientReportController.groovy:90)
>        at no.nsb.rapp.client.ClientReportController$_closure4.doCall(ClientReportController.groovy)
>        at grails.plugin.springcache.web.GrailsFragmentCachingFilter.doFilter(GrailsFragmentCachingFilter.groovy:66)
>        at net.sf.ehcache.constructs.web.filter.Filter.doFilter(Filter.java:86)
>        at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:157)
>        at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:131)
>        at java.lang.Thread.run(Thread.java:680)
>
>
> Using exactly the same parameters to 'update' works fine:
>
> db.counters.update([_id: "entryId"], [$inc: ['c':1]])
>
> and it looks to me that the signature of 'findAndModify' is equal to the signature of 'update':
>
>   public com.mongodb.WriteResult update(com.mongodb.DBObject q, com.mongodb.DBObject o) throws com.mongodb.MongoException
>   public com.mongodb.DBObject findAndModify(com.mongodb.DBObject query, com.mongodb.DBObject update)
>
>
> I also tried adding 'as BasicDBObject' to the parameters, like on this blog: http://jameswilliams.be/blog/entry/165
> But to no success
>
> Do anyone have a solution to this?
>
> Thanks,
> Ronny Løvtangen
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>



--
Graeme Rocher
Grails Project Lead
SpringSource - A Division of VMware
http://www.springsource.com

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Using findAndModify with GMongo

Ronny Løvtangen
Thanks Graeme.

I think the problem is with GMongo.
The Java driver takes 2 DBObject parameters for update as well, but with GMongo you use maps, and then there's some magic happening. But for some reason this magic does not happen with findAndModify. Maybe GMongo has no support for findAndModify yet, so I have to use the Java driver directly.

Ronny

On Oct 5, 2011, at 5:30 PM, Graeme Rocher wrote:

> This isn't really a Groovy question and is more appropriate for the
> MongoDB mailing list since it relates to use of the MongoDB Java
> driver.
>
> Anyway looking at the javadoc
>
> http://api.mongodb.org/java/2.6.5/com/mongodb/DBCollection.html#findAndModify(com.mongodb.DBObject,
> com.mongodb.DBObject)
>
> findAndModify takes 2 DBObject parameters not maps
>
> Cheers
>
> On Wed, Oct 5, 2011 at 8:11 AM, Ronny Løvtangen <[hidden email]> wrote:
>> I'm trying to make an auto incrementing field in MongoDB as described here: http://www.mongodb.org/display/DOCS/How+to+Make+an+Auto+Incrementing+Field
>>
>> Here's my field:
>>
>>> db.counters.find()
>> { "_id" : "entryId", "c" : 1 }
>>
>>
>>
>> I tried to use findAndModify from GMongo like this:
>>
>> def counter = db.counters.findAndModify([_id: "entryId"], [$inc: ['c':1]])
>>
>> which gives me the exception:
>>
>> groovy.lang.MissingMethodException: No signature of method: com.mongodb.DBApiLayer$MyCollection.findAndModify() is applicable for argument types: (java.util.LinkedHashMap, java.util.LinkedHashMap) values: [[_id:entryId], [$inc:[c:1]]]
>> Possible solutions: findAndModify(com.mongodb.DBObject, com.mongodb.DBObject), findAndModify(com.mongodb.DBObject, com.mongodb.DBObject, com.mongodb.DBObject)
>>        at com.gmongo.internal.Patcher$__patchInternal_closure1.doCall(Patcher.groovy:41)
>>        at no.nsb.rapp.client.ClientReportController$_closure4.doCall(ClientReportController.groovy:90)
>>        at no.nsb.rapp.client.ClientReportController$_closure4.doCall(ClientReportController.groovy)
>>        at grails.plugin.springcache.web.GrailsFragmentCachingFilter.doFilter(GrailsFragmentCachingFilter.groovy:66)
>>        at net.sf.ehcache.constructs.web.filter.Filter.doFilter(Filter.java:86)
>>        at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:157)
>>        at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:131)
>>        at java.lang.Thread.run(Thread.java:680)
>>
>>
>> Using exactly the same parameters to 'update' works fine:
>>
>> db.counters.update([_id: "entryId"], [$inc: ['c':1]])
>>
>> and it looks to me that the signature of 'findAndModify' is equal to the signature of 'update':
>>
>>   public com.mongodb.WriteResult update(com.mongodb.DBObject q, com.mongodb.DBObject o) throws com.mongodb.MongoException
>>   public com.mongodb.DBObject findAndModify(com.mongodb.DBObject query, com.mongodb.DBObject update)
>>
>>
>> I also tried adding 'as BasicDBObject' to the parameters, like on this blog: http://jameswilliams.be/blog/entry/165
>> But to no success
>>
>> Do anyone have a solution to this?
>>
>> Thanks,
>> Ronny Løvtangen
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>    http://xircles.codehaus.org/manage_email
>>
>>
>>
>
>
>
> --
> Graeme Rocher
> Grails Project Lead
> SpringSource - A Division of VMware
> http://www.springsource.com
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Using findAndModify with GMongo

Paulo Gabriel Poiati
Hello Ronny, I know what is the problem, it's with GMongo. I will fix it asap.

Tks.

[]'s
Paulo Poiati

blog.paulopoiati.com


On Wed, Oct 5, 2011 at 2:08 PM, Ronny Løvtangen <[hidden email]> wrote:
Thanks Graeme.

I think the problem is with GMongo.
The Java driver takes 2 DBObject parameters for update as well, but with GMongo you use maps, and then there's some magic happening. But for some reason this magic does not happen with findAndModify. Maybe GMongo has no support for findAndModify yet, so I have to use the Java driver directly.

Ronny

On Oct 5, 2011, at 5:30 PM, Graeme Rocher wrote:

> This isn't really a Groovy question and is more appropriate for the
> MongoDB mailing list since it relates to use of the MongoDB Java
> driver.
>
> Anyway looking at the javadoc
>
> http://api.mongodb.org/java/2.6.5/com/mongodb/DBCollection.html#findAndModify(com.mongodb.DBObject,
> com.mongodb.DBObject)
>
> findAndModify takes 2 DBObject parameters not maps
>
> Cheers
>
> On Wed, Oct 5, 2011 at 8:11 AM, Ronny Løvtangen <[hidden email]> wrote:
>> I'm trying to make an auto incrementing field in MongoDB as described here: http://www.mongodb.org/display/DOCS/How+to+Make+an+Auto+Incrementing+Field
>>
>> Here's my field:
>>
>>> db.counters.find()
>> { "_id" : "entryId", "c" : 1 }
>>
>>
>>
>> I tried to use findAndModify from GMongo like this:
>>
>> def counter = db.counters.findAndModify([_id: "entryId"], [$inc: ['c':1]])
>>
>> which gives me the exception:
>>
>> groovy.lang.MissingMethodException: No signature of method: com.mongodb.DBApiLayer$MyCollection.findAndModify() is applicable for argument types: (java.util.LinkedHashMap, java.util.LinkedHashMap) values: [[_id:entryId], [$inc:[c:1]]]
>> Possible solutions: findAndModify(com.mongodb.DBObject, com.mongodb.DBObject), findAndModify(com.mongodb.DBObject, com.mongodb.DBObject, com.mongodb.DBObject)
>>        at com.gmongo.internal.Patcher$__patchInternal_closure1.doCall(Patcher.groovy:41)
>>        at no.nsb.rapp.client.ClientReportController$_closure4.doCall(ClientReportController.groovy:90)
>>        at no.nsb.rapp.client.ClientReportController$_closure4.doCall(ClientReportController.groovy)
>>        at grails.plugin.springcache.web.GrailsFragmentCachingFilter.doFilter(GrailsFragmentCachingFilter.groovy:66)
>>        at net.sf.ehcache.constructs.web.filter.Filter.doFilter(Filter.java:86)
>>        at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:157)
>>        at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:131)
>>        at java.lang.Thread.run(Thread.java:680)
>>
>>
>> Using exactly the same parameters to 'update' works fine:
>>
>> db.counters.update([_id: "entryId"], [$inc: ['c':1]])
>>
>> and it looks to me that the signature of 'findAndModify' is equal to the signature of 'update':
>>
>>   public com.mongodb.WriteResult update(com.mongodb.DBObject q, com.mongodb.DBObject o) throws com.mongodb.MongoException
>>   public com.mongodb.DBObject findAndModify(com.mongodb.DBObject query, com.mongodb.DBObject update)
>>
>>
>> I also tried adding 'as BasicDBObject' to the parameters, like on this blog: http://jameswilliams.be/blog/entry/165
>> But to no success
>>
>> Do anyone have a solution to this?
>>
>> Thanks,
>> Ronny Løvtangen
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>    http://xircles.codehaus.org/manage_email
>>
>>
>>
>
>
>
> --
> Graeme Rocher
> Grails Project Lead
> SpringSource - A Division of VMware
> http://www.springsource.com
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Using findAndModify with GMongo

Ronny Løvtangen
Fabulous, Paulo!
Thanks :)

Ronny

On Oct 5, 2011, at 7:34 PM, Paulo Gabriel Poiati wrote:

Hello Ronny, I know what is the problem, it's with GMongo. I will fix it asap.

Tks.

[]'s
Paulo Poiati

blog.paulopoiati.com


On Wed, Oct 5, 2011 at 2:08 PM, Ronny Løvtangen <[hidden email]> wrote:
Thanks Graeme.

I think the problem is with GMongo.
The Java driver takes 2 DBObject parameters for update as well, but with GMongo you use maps, and then there's some magic happening. But for some reason this magic does not happen with findAndModify. Maybe GMongo has no support for findAndModify yet, so I have to use the Java driver directly.

Ronny

On Oct 5, 2011, at 5:30 PM, Graeme Rocher wrote:

> This isn't really a Groovy question and is more appropriate for the
> MongoDB mailing list since it relates to use of the MongoDB Java
> driver.
>
> Anyway looking at the javadoc
>
> http://api.mongodb.org/java/2.6.5/com/mongodb/DBCollection.html#findAndModify(com.mongodb.DBObject,
> com.mongodb.DBObject)
>
> findAndModify takes 2 DBObject parameters not maps
>
> Cheers
>
> On Wed, Oct 5, 2011 at 8:11 AM, Ronny Løvtangen <[hidden email]> wrote:
>> I'm trying to make an auto incrementing field in MongoDB as described here: http://www.mongodb.org/display/DOCS/How+to+Make+an+Auto+Incrementing+Field
>>
>> Here's my field:
>>
>>> db.counters.find()
>> { "_id" : "entryId", "c" : 1 }
>>
>>
>>
>> I tried to use findAndModify from GMongo like this:
>>
>> def counter = db.counters.findAndModify([_id: "entryId"], [$inc: ['c':1]])
>>
>> which gives me the exception:
>>
>> groovy.lang.MissingMethodException: No signature of method: com.mongodb.DBApiLayer$MyCollection.findAndModify() is applicable for argument types: (java.util.LinkedHashMap, java.util.LinkedHashMap) values: [[_id:entryId], [$inc:[c:1]]]
>> Possible solutions: findAndModify(com.mongodb.DBObject, com.mongodb.DBObject), findAndModify(com.mongodb.DBObject, com.mongodb.DBObject, com.mongodb.DBObject)
>>        at com.gmongo.internal.Patcher$__patchInternal_closure1.doCall(Patcher.groovy:41)
>>        at no.nsb.rapp.client.ClientReportController$_closure4.doCall(ClientReportController.groovy:90)
>>        at no.nsb.rapp.client.ClientReportController$_closure4.doCall(ClientReportController.groovy)
>>        at grails.plugin.springcache.web.GrailsFragmentCachingFilter.doFilter(GrailsFragmentCachingFilter.groovy:66)
>>        at net.sf.ehcache.constructs.web.filter.Filter.doFilter(Filter.java:86)
>>        at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:157)
>>        at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:131)
>>        at java.lang.Thread.run(Thread.java:680)
>>
>>
>> Using exactly the same parameters to 'update' works fine:
>>
>> db.counters.update([_id: "entryId"], [$inc: ['c':1]])
>>
>> and it looks to me that the signature of 'findAndModify' is equal to the signature of 'update':
>>
>>   public com.mongodb.WriteResult update(com.mongodb.DBObject q, com.mongodb.DBObject o) throws com.mongodb.MongoException
>>   public com.mongodb.DBObject findAndModify(com.mongodb.DBObject query, com.mongodb.DBObject update)
>>
>>
>> I also tried adding 'as BasicDBObject' to the parameters, like on this blog: http://jameswilliams.be/blog/entry/165
>> But to no success
>>
>> Do anyone have a solution to this?
>>
>> Thanks,
>> Ronny Løvtangen
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>    http://xircles.codehaus.org/manage_email
>>
>>
>>
>
>
>
> --
> Graeme Rocher
> Grails Project Lead
> SpringSource - A Division of VMware
> http://www.springsource.com
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email




Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Using findAndModify with GMongo

Paulo Gabriel Poiati
Fixed at 0.9.2


It will be available in the maven central in the next few hours.

[]'s
Paulo Poiati

blog.paulopoiati.com


On Wed, Oct 5, 2011 at 2:48 PM, Ronny Løvtangen <[hidden email]> wrote:
Fabulous, Paulo!
Thanks :)

Ronny

On Oct 5, 2011, at 7:34 PM, Paulo Gabriel Poiati wrote:

Hello Ronny, I know what is the problem, it's with GMongo. I will fix it asap.

Tks.

[]'s
Paulo Poiati

blog.paulopoiati.com


On Wed, Oct 5, 2011 at 2:08 PM, Ronny Løvtangen <[hidden email]> wrote:
Thanks Graeme.

I think the problem is with GMongo.
The Java driver takes 2 DBObject parameters for update as well, but with GMongo you use maps, and then there's some magic happening. But for some reason this magic does not happen with findAndModify. Maybe GMongo has no support for findAndModify yet, so I have to use the Java driver directly.

Ronny

On Oct 5, 2011, at 5:30 PM, Graeme Rocher wrote:

> This isn't really a Groovy question and is more appropriate for the
> MongoDB mailing list since it relates to use of the MongoDB Java
> driver.
>
> Anyway looking at the javadoc
>
> http://api.mongodb.org/java/2.6.5/com/mongodb/DBCollection.html#findAndModify(com.mongodb.DBObject,
> com.mongodb.DBObject)
>
> findAndModify takes 2 DBObject parameters not maps
>
> Cheers
>
> On Wed, Oct 5, 2011 at 8:11 AM, Ronny Løvtangen <[hidden email]> wrote:
>> I'm trying to make an auto incrementing field in MongoDB as described here: http://www.mongodb.org/display/DOCS/How+to+Make+an+Auto+Incrementing+Field
>>
>> Here's my field:
>>
>>> db.counters.find()
>> { "_id" : "entryId", "c" : 1 }
>>
>>
>>
>> I tried to use findAndModify from GMongo like this:
>>
>> def counter = db.counters.findAndModify([_id: "entryId"], [$inc: ['c':1]])
>>
>> which gives me the exception:
>>
>> groovy.lang.MissingMethodException: No signature of method: com.mongodb.DBApiLayer$MyCollection.findAndModify() is applicable for argument types: (java.util.LinkedHashMap, java.util.LinkedHashMap) values: [[_id:entryId], [$inc:[c:1]]]
>> Possible solutions: findAndModify(com.mongodb.DBObject, com.mongodb.DBObject), findAndModify(com.mongodb.DBObject, com.mongodb.DBObject, com.mongodb.DBObject)
>>        at com.gmongo.internal.Patcher$__patchInternal_closure1.doCall(Patcher.groovy:41)
>>        at no.nsb.rapp.client.ClientReportController$_closure4.doCall(ClientReportController.groovy:90)
>>        at no.nsb.rapp.client.ClientReportController$_closure4.doCall(ClientReportController.groovy)
>>        at grails.plugin.springcache.web.GrailsFragmentCachingFilter.doFilter(GrailsFragmentCachingFilter.groovy:66)
>>        at net.sf.ehcache.constructs.web.filter.Filter.doFilter(Filter.java:86)
>>        at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:157)
>>        at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:131)
>>        at java.lang.Thread.run(Thread.java:680)
>>
>>
>> Using exactly the same parameters to 'update' works fine:
>>
>> db.counters.update([_id: "entryId"], [$inc: ['c':1]])
>>
>> and it looks to me that the signature of 'findAndModify' is equal to the signature of 'update':
>>
>>   public com.mongodb.WriteResult update(com.mongodb.DBObject q, com.mongodb.DBObject o) throws com.mongodb.MongoException
>>   public com.mongodb.DBObject findAndModify(com.mongodb.DBObject query, com.mongodb.DBObject update)
>>
>>
>> I also tried adding 'as BasicDBObject' to the parameters, like on this blog: http://jameswilliams.be/blog/entry/165
>> But to no success
>>
>> Do anyone have a solution to this?
>>
>> Thanks,
>> Ronny Løvtangen
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>    http://xircles.codehaus.org/manage_email
>>
>>
>>
>
>
>
> --
> Graeme Rocher
> Grails Project Lead
> SpringSource - A Division of VMware
> http://www.springsource.com
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email





Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Using findAndModify with GMongo

Ronny Løvtangen
This is what I call service. Works like a charm :)
Thanks, Paulo!

Ronny

On Oct 6, 2011, at 6:50 AM, Paulo Gabriel Poiati wrote:

Fixed at 0.9.2


It will be available in the maven central in the next few hours.

[]'s
Paulo Poiati

blog.paulopoiati.com


On Wed, Oct 5, 2011 at 2:48 PM, Ronny Løvtangen <[hidden email]> wrote:
Fabulous, Paulo!
Thanks :)

Ronny

On Oct 5, 2011, at 7:34 PM, Paulo Gabriel Poiati wrote:

Hello Ronny, I know what is the problem, it's with GMongo. I will fix it asap.

Tks.

[]'s
Paulo Poiati

blog.paulopoiati.com


On Wed, Oct 5, 2011 at 2:08 PM, Ronny Løvtangen <[hidden email]> wrote:
Thanks Graeme.

I think the problem is with GMongo.
The Java driver takes 2 DBObject parameters for update as well, but with GMongo you use maps, and then there's some magic happening. But for some reason this magic does not happen with findAndModify. Maybe GMongo has no support for findAndModify yet, so I have to use the Java driver directly.

Ronny

On Oct 5, 2011, at 5:30 PM, Graeme Rocher wrote:

> This isn't really a Groovy question and is more appropriate for the
> MongoDB mailing list since it relates to use of the MongoDB Java
> driver.
>
> Anyway looking at the javadoc
>
> http://api.mongodb.org/java/2.6.5/com/mongodb/DBCollection.html#findAndModify(com.mongodb.DBObject,
> com.mongodb.DBObject)
>
> findAndModify takes 2 DBObject parameters not maps
>
> Cheers
>
> On Wed, Oct 5, 2011 at 8:11 AM, Ronny Løvtangen <[hidden email]> wrote:
>> I'm trying to make an auto incrementing field in MongoDB as described here: http://www.mongodb.org/display/DOCS/How+to+Make+an+Auto+Incrementing+Field
>>
>> Here's my field:
>>
>>> db.counters.find()
>> { "_id" : "entryId", "c" : 1 }
>>
>>
>>
>> I tried to use findAndModify from GMongo like this:
>>
>> def counter = db.counters.findAndModify([_id: "entryId"], [$inc: ['c':1]])
>>
>> which gives me the exception:
>>
>> groovy.lang.MissingMethodException: No signature of method: com.mongodb.DBApiLayer$MyCollection.findAndModify() is applicable for argument types: (java.util.LinkedHashMap, java.util.LinkedHashMap) values: [[_id:entryId], [$inc:[c:1]]]
>> Possible solutions: findAndModify(com.mongodb.DBObject, com.mongodb.DBObject), findAndModify(com.mongodb.DBObject, com.mongodb.DBObject, com.mongodb.DBObject)
>>        at com.gmongo.internal.Patcher$__patchInternal_closure1.doCall(Patcher.groovy:41)
>>        at no.nsb.rapp.client.ClientReportController$_closure4.doCall(ClientReportController.groovy:90)
>>        at no.nsb.rapp.client.ClientReportController$_closure4.doCall(ClientReportController.groovy)
>>        at grails.plugin.springcache.web.GrailsFragmentCachingFilter.doFilter(GrailsFragmentCachingFilter.groovy:66)
>>        at net.sf.ehcache.constructs.web.filter.Filter.doFilter(Filter.java:86)
>>        at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:157)
>>        at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:131)
>>        at java.lang.Thread.run(Thread.java:680)
>>
>>
>> Using exactly the same parameters to 'update' works fine:
>>
>> db.counters.update([_id: "entryId"], [$inc: ['c':1]])
>>
>> and it looks to me that the signature of 'findAndModify' is equal to the signature of 'update':
>>
>>   public com.mongodb.WriteResult update(com.mongodb.DBObject q, com.mongodb.DBObject o) throws com.mongodb.MongoException
>>   public com.mongodb.DBObject findAndModify(com.mongodb.DBObject query, com.mongodb.DBObject update)
>>
>>
>> I also tried adding 'as BasicDBObject' to the parameters, like on this blog: http://jameswilliams.be/blog/entry/165
>> But to no success
>>
>> Do anyone have a solution to this?
>>
>> Thanks,
>> Ronny Løvtangen
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>    http://xircles.codehaus.org/manage_email
>>
>>
>>
>
>
>
> --
> Graeme Rocher
> Grails Project Lead
> SpringSource - A Division of VMware
> http://www.springsource.com
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email






Loading...