grails - GORM,为带有复合ID的joinTable的列命名

标签 grails gorm

使用Grails 1.3.7,我必须处理旧版数据库。我在连接表中有一个域对象“Cake”,该对象具有其自己的嵌入式“成分”集合。

成分

class Ingredient {
  String name
  IngredientCategory category

  mapping {
    table "foo_ingredient"
    version false
    id composite:['name', 'category']
    columns {
      word     column:"the_name"
     category column:"lol_category_id"
    }
  }

}

Cake.groovy
class Cake {
  String name

  static hasMany = [ ingredients : Ingredient ]

  static mapping = {
    table "foo_cake"
    version false
    columns {
      id   column:"id"
      name column:"the_name"
    }

    ingredients joinTable: [
      name : "foo_cake_ingredient",
      key  : "cake_id"
    ]
  }
}

问题是,Grails希望表“foo_cake_ingredient”具有两列“ingredient_name”和“ingredient_category_id”。我想手动指定那些列名,而不要让Grails(错误地)猜那些。我不知道该怎么做。

最佳答案

关于grails - GORM,为带有复合ID的joinTable的列命名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6067498/

相关文章:

java - 如何正确使用 Hibernate @Index 注解?

hibernate - Grails Spring Security查询没有特定角色的用户

hibernate - 如何使tablePerHierarchy为假并使用鉴别符?

hibernate - GORM条件查询过滤列表中的ID

hibernate - 悲观锁定 : Lock database entity grails

grails - 带有springSecurity的Grails中的MissingMethodException

pdf - 使用ByteArrayOutputStream使用iText将水印添加到pdf

grails - Grails的事务性后台作业

grails - hasMany没有获取记录

hibernate - 命令对象中的 Grails 域对象始终保存