grails / inconsequential Goto Github PK
View Code? Open in Web Editor NEWNote - this is an old repository and the code has been moved to https://github.com/SpringSource/spring-data-mapping
Note - this is an old repository and the code has been moved to https://github.com/SpringSource/spring-data-mapping
Grails Inconsequential ---------------------- Project moved to https://github.com/SpringSource/grails-data-mapping
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"}
hello,
i think the delete method is returning as normal but no collection is removed in the database.
this integration test is passing nicely but the record is not deleted ?!?
i have version 1.0-M4
void testSimpleDelete() {
def oma = new Product();
oma.title = "omaForDeletion";
oma.save(flush: true);
assertNotNull(oma.id);
def id = oma.id; // debugging shows the appropriate hash
Product.get(id).delete(flush: true);
assertNull "product was not null after deleting ", Product.get(id)
}
with the domain class:
class Product {
String id; // for the hash
String title
static mapWith = "mongo"
}
best regards nils
In traditional (Hibernate based) GORM, if one used an embedded mapping it was also necessary for them to define the embedded class in the same file as the embedding class. With MongoDB, this isn't necessary (indeed, it seems it's required that you don't).
Currently the documentation at http://grails.github.com/inconsequential/mongo/manual/guide/3.%20Mapping%20Domain%20Classes%20to%20Mongo%20Collections.html doesn't clarify this, which can be a bit of a stumbling block for those of us converting from a RDBS-based domain model to Mongo.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.