我正在使用在插入序列之前触发的触发器为 Oracle 11g xe 中的表生成 id
这是我的触发器
DROP TRIGGER GOOGLEPLAY.ORGANIZATION_CODE_GENERATOR;
CREATE OR REPLACE TRIGGER GOOGLEPLAY.ORGANIZATION_code_generator
BEFORE INSERT
ON GOOGLEPLAY.ORGANIZATIONS
REFERENCING NEW AS New OLD AS Old
FOR EACH ROW
DECLARE
BEGIN
select ORGANIZATION_SEQ.nextval into :NEW.code from dual;
EXCEPTION
WHEN OTHERS
THEN
-- Consider logging the error and then re-raise
RAISE;
END ORGANIZATION_code_generator;
这是我的顺序
DROP SEQUENCE GOOGLEPLAY.ORGANIZATION_SEQ;
CREATE SEQUENCE GOOGLEPLAY.ORGANIZATION_SEQ
START WITH 41
MAXVALUE 99
MINVALUE 1
NOCYCLE
NOCACHE
NOORDER;
我想使用我正在使用的休眠获取此 ID
session.persist(cashierOrganization);
session.flush();
cashierOrganization = (Organizations) session.merge(cashierOrganization);
但我总是得到 0 的 id 有什么建议吗?