27
votes

I am using Criteria with projections to get a list of tags on my Account domain. Like this:

def tags = Account.createCriteria().list { 
    projections { property("tags") } 
}

My Account domain:

class Account {
    static mapWith = "mongo"
    List<Tag> tags
    ...
    static embedded = ['tags']
}

BuildConfig.groovy

// using grails 2.3.8
plugins {
    runtime ":hibernate:3.6.10.17"
    compile ":mongodb:2.0.1"

This worked until I upgraded the MongoDB GORM plugin for grails from 2.0.1 to 3.0.1

    compile ":mongodb:3.0.1"

Now I see the following error...

The class [java.util.List] is not a known persistent type.
    at org.grails.datastore.mapping.core.AbstractSession.retrieveAll(AbstractSession.java:723)
    at org.grails.datastore.mapping.mongo.query.MongoQuery$AggregatedResultList.initializeFully(MongoQuery.java:1601)
    at org.grails.datastore.mapping.mongo.query.MongoQuery$AggregatedResultList.size(MongoQuery.java:1764)

Why did this work before but is failing now? I don't want to rewrite all my existing queries to use mongoDB's aggregation framework.

2
Did you ever find a fix or run this through a debugger to see what has changed in the method calls from 2.0.1 to 3.0.1?th3morg
This is a bit of an old question, but have you tried removing the Hibernate runtime? I know there is a conflict with Mongo and Hibernate.kevingreen
Hello, Trying to clen up unanswered. Did you solve this? Maybe you can answer your own question.Neoryder

2 Answers

0
votes

You can try the usual

grails clean
grails refresh-dependencies

Also check for a newer version of your plugin.

Another alternative is switch to this mongo plugin published a month ago, which is supposed to be compatible with GORM for Hibernate

'org.grails.plugins:mongodb:6.0.0.M2'
-1
votes

You can avoid the conflict by removing hibernate from your plug-in manager