Coder Social home page Coder Social logo

Comments (2)

alexduan avatar alexduan commented on July 17, 2024

This issue should be closed with release 0.6.1 and 0.6.2

from gorm-mongodb.

countvajhula avatar countvajhula commented on July 17, 2024

Hello, I am seeing this issue in my app, and I am using version 0.7.3.

I think it might have something to do with the plugin automatically inserting an ObjectId id field if you don't manually specify an id field. As a result, the parent object gets an automatic ObjectId id and the same happens for the child class, and this results in the duplicates. But I'm not sure.

To give you a full picture of what I am doing:
I have 6-7 classes created in /mongo via create-mongodb-class. One of these is the base class MongoObject, which contains many fields that are common to all other classes. 4-5 other classes extend MongoObject. There is another class called ParentClassA which extends MongoObject, and which further has two children of its own, ClassB and ClassC.

If I try to run my grails app with this setup, I get complaints like:

  1. "EmbeddedAndId": Embedded classes cannot have an _id -- this is because one of the classes in /mongo is actually an embedded class, and it extends the base class MongoObject which apparently automatically gets an ObjectId field even if I don't specify one.
  2. " field name '_id' is duplicated; you cannot map different java fields to the same MongoDB field." -- if classes in /mongo where an @id field is not specified are automatically being assigned an ObjectId by the gorm-mongodb plugin (as I suspect), then this is probably a result of both MongoObject and any child class each receiving an ObjectId.

Attempted workaround:
If I move the class MongoObject into a different folder (src/groovy) as indicated in one of the above comments, and leave out the @entity annotation, then the above errors go away.

BUT: I'm not sure if this works yet, since I am unable to get the @AlsoLoad annotation working in this (or any) configuration. It's probably unrelated to this issue, but until the app is fully working I can't be sure that this is a valid workaround (I've reported this separate issue on the morphia mailing list: http://groups.google.com/group/morphia/browse_thread/thread/b74cca98a021db1a# )

Thanks.

from gorm-mongodb.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.