grails - 除了使用 transient 关键字之外,还有其他任何方法可以阻止Grails域类中字段(也是域类对象)的持久性吗?

标签 grails gorm grails-2.0 grails-domain-class

class ContentA{
  String name
  ContentB[] contentBList
}

class contentB{
  Long typeId
  String typeName
}

ContentA和ContentB都是域对象,将在各自的调用中填充
享受我们提供的 Restful 服务。

org.hibernate.MappingException: Could not determine type for: [Lcom.classes.ContentB;, at table: table_name, for columns: [org.hibernate.mapping.Column(content_b_list)



构建应用程序时,我们会收到上述错误。
当我们将ContentB添加到static transients{}时,它不会在生成的json字符串中呈现。我们使用json调用与服务进行交互,并将Domain对象转换为json
字符串。还有其他方法可以使ORM停止持久化contentB吗?

我们甚至尝试使用CustomMarshaller生成效果不佳的json字符串。

最佳答案

您需要定义关联

class ContentA {
      String name
      static hasMany = [contentBList: ContentB]
}

GORM oneToMany

关于grails - 除了使用 transient 关键字之外,还有其他任何方法可以阻止Grails域类中字段(也是域类对象)的持久性吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27314342/

相关文章:

grails - 如何在Grails中最好地实现短代码之类的东西

sql-server - 使用可信连接将 Grails 连接到 MS SQL

grails - 将SQL查询转换为GORM条件

hibernate - Grails GORM映射尝试访问不存在的字段 “class”

Grails 所需的验证器在 Safari 浏览器中不起作用?

mysql - GORM 多对一映射表

Grails 布局资源相当于 asset-pipeline

mongodb - Grails过渡属性无法验证错误?

用于 Grails 2.0 的 Grails/Gradle 插件

Grails 2.4.4 无法创建 codecLookup bean