Skip to content

GPMONGODB-340: When doing a findById on a domain object when the id is of the type ObjectId exception thrown #453

@graemerocher

Description

@graemerocher

Original Reporter: sjwhyte
Environment: Linux
Version: 1.3.3
Migrated From: http://jira.grails.org/browse/GPMONGODB-340

When trying to retrieve a domain object:

{code:title=}
class Device {

ObjectId id
Organization organization
User assignedUser

}
{code}

and by doing a findById as with a domain object like :

{code}
//Trying with a String
def deviceId = "2e:20:8b:40:4e:01"
Device.find(deviceId)
{code}

I get a groovy.lang.MissingMethodException: No signature of method: static com.xoeye.Device.findById() is applicable for argument types: (java.lang.String) values: [2e:20:8b:40:4e:01]
Possible solutions: find(), findAll(), find(groovy.lang.Closure), findAll(groovy.lang.Closure)

When I try to do it the following way:
{code}
//Trying with a String
def deviceId = new ObjectId("2e:20:8b:40:4e:01")
Device.find(deviceId)
{code}

The Mongo-Java driver throws an IllegalArgumentException because the isValid method on the ObjectId class does not allow ":" in the id and my string is less than 24 bits.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions