代码之家  ›  专栏  ›  技术社区  ›  yura

如何更改Grails中的列名约定?

  •  4
  • yura  · 技术社区  · 14 年前

    2 回复  |  直到 14 年前
        1
  •  6
  •   Cristan    8 年前

    可以更改整个项目的命名策略。从文档中 https://grails.github.io/grails-doc/latest/guide/GORM.html#customNamingStrategy .

    默认情况下,Grails使用Hibernate的 改进的NamingStrategy转换 域类和字段名 SQL表和列名 用下划线做单词的人 映射中每个实例的基础 但如果有一个 您可以指定不同的模式 要使用的NamingStrategy类。

    所以,在你的生活中数据源.groovy

    dataSource {
        pooled = true
        dbCreate = "create-drop"
         …
    }
    hibernate {
        cache.use_second_level_cache = true
         …
        naming_strategy = org.hibernate.cfg.DefaultNamingStrategy
    }
    
        2
  •  8
  •   Aaron Saunders    14 年前

    5.5.2.1 Table and Column Names

    class Person {
      String firstName
      static mapping = {
          table 'people'
          firstName column:'firstname'
      }
    }