Oracle 11g 的 Grails 序列生成 [英] Grails sequence generation for Oracle 11g

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

问题描述

我意识到这比 Grails 更像是一个休眠问题.在负载平衡(2 个节点)环境中,我看到我的对象的 id 有很多跳跃.即使没有重新启动应用程序服务器,我也会看到数字跳过 10 有时是 20 个数字.我怀疑休眠会话正在缓存一个序列值块.有没有办法用 grails 1.3.7 控制这种行为?基本上我可以接受服务器每次需要时从数据库中提取 nextval.

I realize this is more of a hibernate question than Grails. In a load balanced (2 nodes) environment I see that the ids of my objects are jumping around quite a bit. Even without restarting the app server I see that the numbers skip 10 sometimes 20 numbers. I suspect the hibernate session is caching a block of sequence values. Is there a way to control this behavior with grails 1.3.7 ? Essentially I am OK with server pulling nextval from DB every time it needs one.

我的域对象序列声明(2个对象相同):

My domain object sequence declaration (same for 2 objects):

static mapping = {
        id generator:'sequence', params:[sequence:'MY_SEQ']  
    } 

推荐答案

此后,我前往数据库并使用以下 DDL 修改了序列:

I have since went to the database and modified the Sequence with the following DDL:

ALTER SEQUENCE MY_SEQ NOCACHE;

我认为这是解决此问题的最佳解决方案.有没有人看到这种方法的潜在问题?

I think this is the best solution for this issue. Does anyone see potential problems with this approach?

谢谢大家!

这篇关于Oracle 11g 的 Grails 序列生成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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