Upgrading Grails MongoDB GORM broke projections on list properties
Asked Answered
A

2

34

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.

Adytum answered 2/9, 2014 at 23:8 Comment(3)
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?Rigidify
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.Forehead
Hello, Trying to clen up unanswered. Did you solve this? Maybe you can answer your own question.Craftwork
M
1

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'
Mew answered 24/8, 2016 at 15:7 Comment(0)
R
-1

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

Rowdy answered 8/6, 2015 at 14:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.