如何使用MongoDB将域引用存储为Grails中另一个域的动态属性?

时间:2013-02-18 13:28:37

标签: mongodb grails gorm

我希望能够将对象的引用存储为另一个域的动态属性。 不幸的是,当我尝试保存这样的域对象时,我得到:

| Error 2013-02-18 14:03:09,352 [localhost-startStop-1] ERROR context.GrailsContextLoader  - Error initializing the application: can't serialize class Employee
Message: can't serialize class Employee

这是代码[Machine&员工是域名:

def m = new Machine(name: "Machine 01")
def e = Employee.findByName("employee name")
m['operator'] = e
m.save(failOnError: true)

我想知道这是否可行?我认为应该没有列出mongodb插件的限制[我使用1.1.0GA与Grails 2.2.0]。

class Machine {
    String name
}

class Employee {
    String name
}

0 个答案:

没有答案