You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Example that reproduces the problem uploaded to Github
Full description of the issue provided (see below)
When using Inheritance from an abstract base class as an embedded object, the list criteria query throws java.lang.InstantiationException.
Steps to Reproduce
Create a Grails 4 application.
Remove hibernate dependencies and add the Grails MongoDB plugin.
Create an abstract base domain class Address as:
abstract class Address {
String street
}
Create another domain class HomeAddress.groovy which implements Address as:
class HomeAddress extends Address {
String type = "home"
}
Create a domain class Patient.groovy which as embedded address as:
class Patient {
Address address
static embedded = ['address']
}
Try to access list of all patient using following query:
Patient.list()
Expected Behaviour
The query Patient.list() should return all the patients with embedded address information without any error.
Actual Behaviour
The following exception is thrown:
Caused by: java.lang.reflect.UndeclaredThrowableException
at org.grails.datastore.mapping.core.DatastoreUtils.execute(DatastoreUtils.java:319)
at org.grails.datastore.gorm.AbstractDatastoreApi.execute(AbstractDatastoreApi.groovy:40)
at org.grails.datastore.gorm.GormStaticApi.list(GormStaticApi.groovy:607)
at org.grails.datastore.gorm.GormEntity$Trait$Helper.list(GormEntity.groovy:682)
... 1 more
Caused by: java.lang.InstantiationException
at org.grails.datastore.bson.codecs.BsonPersistentEntityCodec.decode(BsonPersistentEntityCodec.groovy:76)
at org.grails.datastore.bson.codecs.decoders.EmbeddedDecoder.decode(EmbeddedDecoder.groovy:27)
at org.grails.datastore.bson.codecs.BsonPersistentEntityCodec.decode(BsonPersistentEntityCodec.groovy:121)
at com.mongodb.operation.CommandResultArrayCodec.decode(CommandResultArrayCodec.java:52)
at com.mongodb.operation.CommandResultDocumentCodec.readValue(CommandResultDocumentCodec.java:60)
at org.bson.codecs.BsonDocumentCodec.decode(BsonDocumentCodec.java:84)
at org.bson.codecs.BsonDocumentCodec.decode(BsonDocumentCodec.java:41)
at org.bson.codecs.configuration.LazyCodec.decode(LazyCodec.java:47)
at org.bson.codecs.BsonDocumentCodec.readValue(BsonDocumentCodec.java:101)
at com.mongodb.operation.CommandResultDocumentCodec.readValue(CommandResultDocumentCodec.java:63)
at org.bson.codecs.BsonDocumentCodec.decode(BsonDocumentCodec.java:84)
at org.bson.codecs.BsonDocumentCodec.decode(BsonDocumentCodec.java:41)
at com.mongodb.internal.connection.ReplyMessage.<init>(ReplyMessage.java:48)
at com.mongodb.internal.connection.InternalStreamConnection.getCommandResult(InternalStreamConnection.java:393)
at com.mongodb.internal.connection.InternalStreamConnection.receiveCommandMessageResponse(InternalStreamConnection.java:299)
at com.mongodb.internal.connection.InternalStreamConnection.sendAndReceive(InternalStreamConnection.java:255)
at com.mongodb.internal.connection.UsageTrackingInternalConnection.sendAndReceive(UsageTrackingInternalConnection.java:99)
at com.mongodb.internal.connection.DefaultConnectionPool$PooledConnection.sendAndReceive(DefaultConnectionPool.java:444)
at com.mongodb.internal.connection.CommandProtocolImpl.execute(CommandProtocolImpl.java:72)
at com.mongodb.internal.connection.DefaultServer$DefaultServerProtocolExecutor.execute(DefaultServer.java:200)
at com.mongodb.internal.connection.DefaultServerConnection.executeProtocol(DefaultServerConnection.java:269)
at com.mongodb.internal.connection.DefaultServerConnection.command(DefaultServerConnection.java:131)
at com.mongodb.internal.connection.DefaultServerConnection.command(DefaultServerConnection.java:123)
at com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:242)
at com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:233)
at com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:136)
at com.mongodb.operation.FindOperation$1.call(FindOperation.java:701)
at com.mongodb.operation.FindOperation$1.call(FindOperation.java:695)
at com.mongodb.operation.OperationHelper.withConnectionSource(OperationHelper.java:462)
at com.mongodb.operation.OperationHelper.withConnection(OperationHelper.java:406)
at com.mongodb.operation.FindOperation.execute(FindOperation.java:695)
at com.mongodb.operation.FindOperation.execute(FindOperation.java:83)
at com.mongodb.client.internal.MongoClientDelegate$DelegateOperationExecutor.execute(MongoClientDelegate.java:179)
at com.mongodb.client.internal.MongoIterableImpl.execute(MongoIterableImpl.java:132)
at com.mongodb.client.internal.MongoIterableImpl.iterator(MongoIterableImpl.java:86)
at org.grails.datastore.mapping.mongo.query.MongoQuery.executeQuery(MongoQuery.java:527)
at org.grails.datastore.mapping.mongo.query.MongoQuery.executeQuery(MongoQuery.java:464)
at org.grails.datastore.mapping.query.Query.doList(Query.java:589)
at org.grails.datastore.mapping.query.Query.list(Query.java:568)
at org.grails.datastore.gorm.GormStaticApi.list_closure20(GormStaticApi.groovy:608)
at groovy.lang.Closure.call(Closure.java:405)
... 5 more
Environment Information
Operating System: macOS
Grails Version: 4.0.3
JDK Version: 1.8.hs-adpt
Container Version (If Applicable): MongoDB 3 Docker Image
Task List
When using Inheritance from an abstract base class as an embedded object, the
list
criteria query throwsjava.lang.InstantiationException
.Steps to Reproduce
Address
as:HomeAddress.groovy
which implementsAddress
as:Patient.groovy
which as embedded address as:Expected Behaviour
The query
Patient.list()
should return all the patients with embedded address information without any error.Actual Behaviour
The following exception is thrown:
Environment Information
Example Application
The text was updated successfully, but these errors were encountered: