hibernate + oracle 映射主键问题

1.hibernate + oracle 映射主键问题 Copy to clipboard Posted by: ybbkd2 Posted on: 2005-07-16 11:23 我先设置主键class_ID 为 : cls.setClassName("专访"); cls.setClassNotes("专访专用栏目"); cls.setClassIntr("打造企业,诉说故事"); 保存时错误提示: Hibernate: select hibernate_sequence.nextval from dual net.sf.hibernate.exception.GenericJDBCException: Could not save object Caused by: java.sql.SQLException: ORA-02289: 序列(号)不存在 我想使用 触发器+sequence 数据库自动维护ID号生成,不需要程序干预,如何做 ? 希望能找到答案!! 附: /* -------------- oracle sp.sql begin -------------------------*/ Create table btcn_news_class ( class_id Integer Default 0 NOT NULL , class_name Varchar2(10) Default '' NOT NULL , class_intr Clob Default '' NOT NULL , class_notes Varchar2(4000) Default '' NOT NULL , parent Integer Default 0 NOT NULL ) / Alter table btcn_news_class add Constraint pk_btcn_news_class primary key (class_id) / create sequence news_class_id minvalue 1 maxvalue 999999999999999999999999999 start with 1 increment by 1 cache 20 order; /* Trigger for sequence news_class_id for table btcn_news_class attribute class_id */ Create or replace trigger t_news_class_id before insert on btcn_news_class for each row begin SELECT news_class_id.nextval INTO :new.class_id FROM dual; end; / /* ---------- sp.sql end. -------------- */ 下面是hbm.xml 对主键的映射(myeclipse 生成的):

 

-------------------------------------------------------------------------------- 2.Re:hibernate + oracle 映射主键问题 [Re: ybbkd2] Copy to clipboard Posted by: youlq Posted on: 2005-07-18 08:50 old: new: SEQ_CLASS_ID note:SEQ_CLASS_ID is the name of your sequence

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值