Skip to content

GPMONGODB-12: Unable to embed a list of objects #525

@graemerocher

Description

@graemerocher

Original Reporter: alexduan
Environment: Grails 1.3.6, MongoDB-1.0.M4
Version: Not Specified
Migrated From: http://jira.grails.org/browse/GPMONGODB-12

For a class Email:

{code}
class Email {
String address
}
{code}

If I try to embed it into my Person:

{code}
class Person {
Email email
static embedded = ['email']
}
{code}

This works fine. When I try to embed a list of Emails with either:

{code}
class Person {
static hasMany = [emails:Email]
static embedded = ['emails']
}
{code}

or:

{code}
class Person {
List emails
static hasMany = [emails:Email]
static embedded = ['emails']
}
{code}

The document that is stored in Mongo looks like:

{code}
{"_id" : NumberLong(1), "emails" : [ NumberLong(1) ] }
{code}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions