修改Grails插件的ID生成 [英] Modify Id generation for a Grails Plugin

查看:211
本文介绍了修改Grails插件的ID生成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为Grails使用插件 - Amazon S3插件 - 并且由插件提供的域对象不指定Id生成器。我使用的是Postgresql,并要求id生成器是身份证明。



我可以将插件复制到我的插件目录中,并且混淆了提供的域对象,但听起来没有声音像一个干净的方法。我可以在运行时添加正确的id代?或者也许有更好的方法。

解决方案

如果您使用1.2,您可以为所有GORM类提供默认映射,包括发电机。

  grails.gorm.default.mapping = {
id generator:'sequence'
}

更多信息见 1.2发行说明

I am using a plugin for Grails - the Amazon S3 plugin - and the domain object provided by the plugin doesn't specify the Id Generator. I am using Postgresql and require the id genrator to be identity.

I could copy the plugin in my plugins directory and mess with the domain object provided but that doesn't sound like a clean approach.Could I add the correct id generation at runtime? Or maybe there is a better way.

解决方案

If you are using 1.2, you could provide a default mapping for all your GORM classes, including generator.

grails.gorm.default.mapping = {
   id generator:'sequence'
}

See more in 1.2 release notes.

这篇关于修改Grails插件的ID生成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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