覆盖Grails中的默认序列名称 [英] Override default sequence name in Grails

查看:94
本文介绍了覆盖Grails中的默认序列名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何重命名HIBERNATE_SEQUENCE?每个表格生成一个序列的方法(并给出了这些序列的具体名称)都有详细记录,但这不是我要找的。我不介意所有域类都有一个序列共享 - 我只需要给它一个特定于应用程序的名称即可。 解决方案

在Hibernate JIRA中似乎有一个开放的功能/增强请求,使其具有全局可配置性:使全局可配置的默认序列名称为。我相信,作为一种解决方法,您必须为每个@Id字段将所有域类(默认为hibernate_sequence)的'generator'属性设置为相同的名称。请参阅创建的oracle序列正如你暗示你的问题,可能有一种方法可以通过继承你的数据库方言来做到这一点 - 正如许多人建议的序列一样-table方法。



请参阅 id generator and DRY principle

How can I rename HIBERNATE_SEQUENCE? Methods for generating one sequence per table (and giving specific names to those sequences) are well-documented, but that's not what I'm looking for. I don't mind having one sequence shared by all domain classes -- I just need to give it an application-specific name.

解决方案

There appears to be an open feature / enhancement request in the Hibernate JIRA to make this globally configurable: Make the default sequence name globally configurable. I believe, as a workaround, you would have to set the 'generator' attribute to the same name for all domain classes (defaults to hibernate_sequence) for every @Id field. See oracle sequence created.

As you hinted in your question, there might be a way to do this by subclassing your database dialect - as many have suggested for a sequence-per-table approach.

See id generator and DRY principle

这篇关于覆盖Grails中的默认序列名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆