could not get next sequence value

    xiaoxiao2025-12-06  3

    </pre>已经解决:could not get next sequence value<p></p><p>自己搭建测试项目,save()时报错。</p><p>【我的环境】</p><p>系统环境:Ubuntukylin14.04+jdk1.7</p><p>开发环境:play freamwork1.2+postgresql9.4.8</p><p>【我的测试】</p><p>项目需要根据不同用户切换到不同schema下,切换也无非是对hibernate的session处理,这个部分没问题,接着我切换后执行新增。</p><p>代码如下:</p><pre name="code" class="java"> public static void adda() { Workeraa w = new Workeraa("a"); w.save(); a(); }

    【我的思路】

    我的数据库的schema的用户对数据库序列操作权限不足

    【解决历程】

    1、\ds 命令查看所有序列

    du=> \ds 关联列表 架构模式 | 名称 | 型别 | 拥有者 ----------+--------------------+--------+---------- public | hibernate_sequence | 序列数 | postgres public | worker_id_seq | 序列数 | postgres (2 行记录) 可以看到有两个序列,并且所有者是postgres管理员。

    2、grant all on hibernate_sequence to myusername;给我创建的角色赋权

    3、操作的时候,默认使用当前schema的序列。

    转载请注明原文地址: https://ju.6miu.com/read-1304658.html
    最新回复(0)