Using mongodb plugin 1.0M4 from http://grails.org/plugin/mongodb
Grails 1.3.7
Test Domain Class:
package com.test
import org.bson.types.ObjectId
class Person {
static mapWith = "mongo"
ObjectId id
String name
// Address address
// static embedded = ['address']
// static hasMany = [pets: Pet]
static mapping = {
name index: true, indexAttributes: [unique: true, dropDups: true]
//writeConcern WriteConcern.FSYNC_SAFE
// collection "mycollection"
// database "mydb"
// firstName field:"first_name"
}
static constraints = {
}
}
Create a new person and save it, no issue.
Edit the just created person, click update, go to mongodb shell, observe duplicate id fields present for the person instance.
In db:
{ "_id" : ObjectId("4d73a087f3f930d606e3c5b5"), "name" : "my name", "id" : ObjectId("4d73a087f3f930d606e3c5b5") }
Expected:
{ "_id" : ObjectId("4d73a087f3f930d606e3c5b5"), "name" : "my name"}