【问题标题】:grails hasMany with POJO domain classgrails hasMany 与 POJO 域类
【发布时间】:2014-10-21 02:28:30
【问题描述】:

我在 /src/java 中放置了以下带注释的 POJO:

@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public class A {
    @Id 
    public String id; 
    @OneToMany(fetch=FetchType.Lazy)
    List<A> As;
    ...
}

我在 hibernate.cfg.xml 中声明了这个类,并且能够使用动态脚手架为这个域生成一个 crud 接口。

然后我尝试将域 A 与来自 grails 域的 hasMany 联系使用:

class B {
   List<A> children=[]
   static hasMany = [ children :  mypackage.A ]
}

我不能再运行App了,grails在抱怨:

org.hibernate.MappingException: Missing type or column for column[childrens_A]
on domain[B] referencing[mypackage.A]

【问题讨论】:

  • 不要放在 src/java/.就这么简单
  • 您的意思是将 POJO 从 src/java/ 移动到 grails-app/domain 吗?刚试了一下,没啥变化。
  • 制作一个普通的 groovy 域类,没有所有那些有趣的注释
  • 是的,但我想使用这里描述的pojos:link

标签: hibernate grails grails-orm pojo


【解决方案1】:

https://jira.grails.org/browse/GRAILS-11727

显然,域可以是 hibernate 或 gorm 语法,但不能同时使用。

【讨论】:

    猜你喜欢
    • 2014-07-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-09
    相关资源
    最近更新 更多