Comments (2)
This issue should be closed with release 0.6.1 and 0.6.2
from gorm-mongodb.
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:
- "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.
- " 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)
- Runtime Error HOT 1
- Domain.list() return MorphiaIterator when GORM semantics are slightly different HOT 1
- Getting an error when trying a simple Domain Class
- Trying to use generated scaffolding causes error
- errorr in the install script HOT 1
- Unable to resolve class HOT 1
- did it support "unique" save? HOT 2
- Getting exception "com.mongodb.BasicDBObject cannot be cast to com.mongodb.DBRef" HOT 2
- (obvious) Don't think this is working with Grails 1.4 HOT 2
- Advanced Querying using this plugin HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gorm-mongodb.