Skip to content

GPMONGODB-337: CLONE - Accessing hasMany set with objects will throw the exception: com.mongodb.DBRef cannot be cast to java.io.Serializable #301

@graemerocher

Description

@graemerocher

Original Reporter: rainbow
Environment: Not Specified
Version: 1.2.0.GA
Migrated From: http://jira.grails.org/browse/GPMONGODB-337

When trying to access hasMany set with objects in a new session, the following error will be thrown:

com.mongodb.DBRef cannot be cast to java.io.Serializable
java.lang.ClassCastException: com.mongodb.DBRef cannot be cast to java.io.Serializable
at org.grails.datastore.mapping.core.AbstractSession.retrieveAll(AbstractSession.java:661)
at org.grails.datastore.mapping.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:206)
at org.grails.datastore.mapping.collection.AbstractPersistentCollection.size(AbstractPersistentCollection.java:88)
at UserObjectsTests$_getAllSavedDataWithANewSession_closure1.doCall(UserObjectsTests.groovy:38)
at org.grails.datastore.gorm.GormStaticApi.withNewSession(GormStaticApi.groovy:731)
at org.grails.datastore.gorm.StaticMethodInvokingClosure.call(GormEnhancer.groovy:288)
at UserObjectsTests.getAllSavedDataWithANewSession(UserObjectsTests.groovy:33)
at UserObjectsTests.testUserObjectsCreation(UserObjectsTests.groovy:29)

After the exception is thrown, the set will be empty even though the mongoDB contains DBRef to the objects.

See attached integration test to reproduce the issue.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions