You can create a new domain class, SalaryRange:
class SalaryRange {
int min
int max
String descr
static constraints = {
// whatever constraints you need
}
}
Then declare SalaryRange to be embedded in your Employee class:
class Employee {
String firstName
String lastName
SalaryRange salrange
static embedded = ['salrange']
static constraints = {
// whatever constraints you need
}
}
With this there will be only one collection, Employee, each document in that collection will have embedded SalaryRange data.
Good luck,
David
On Tue, Mar 27, 2012 at 9:58 AM, Robert La Ferla
<[hidden email]> wrote:
I want to store an embedded object (not a reference to another collection) in a Mongo domain class..
Let's say this record is in the database:
{
firstName: "John",
lastName: "Smith",
salaryRange: { min: 70000, max: 90000, desc: "something"}
}
class Employee {
String firstName;
String lastName;
Map salaryRange; // ????????????
}
I do not want salaryRange in a separate collection but is there a way to use a class instead of a generic Map for this mapping?
Thanks in advance!
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
--
"It's possible that my whole purpose in life is simply to serve as a warning to others."