首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

2012-01-01 
关于Hibernategenerator classsequence 的问题我没理解错的话,generator classsequence 是在添

关于Hibernate<generator class="sequence" >的问题
我没理解错的话,<generator class="sequence" > 是在添加数据时 该列按照 oracle sequence_name 所制定的规律自动添加。也就是所称的自增长。

然而,我试了几次都出现了以下错误
是不是,我还少什么jar?还是有什么需要设置的?

java.sql.SQLException: ORA-02289: 序列不存在

at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:573)
at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1891)
at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteDescribe(TTC7Protocol.java:830)
at oracle.jdbc.driver.OracleStatement.doExecuteQuery(OracleStatement.java:2391)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2672)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:589)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:527)
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:92)
at org.hibernate.id.SequenceGenerator.generate(SequenceGenerator.java:75)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:91)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:186)
at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:175)
at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:530)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:518)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:514)
at org.springframework.orm.hibernate3.HibernateTemplate$12.doInHibernate(HibernateTemplate.java:635)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:372)
at org.springframework.orm.hibernate3.HibernateTemplate.save(HibernateTemplate.java:632)
at dao.imple.BbsDAO.save(BbsDAO.java:39)
at action.BbsAction.createbbs(BbsAction.java:93)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:270)
at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:187)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)


at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:864)
at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579)
at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1665)
at java.lang.Thread.run(Thread.java:662)



这里是我的hibernate设置 <id name="bbsid" type="java.lang.Long">
  <column name="BBSID" precision="22" scale="0" />
  <generator class="sequence" >
  <param name="sequence">createbbs</param>
  </generator>
  </id>
oracle sequence创建语句:create sequence createbbs
increment by 1
start with 1
nomaxvalue
nocycle;

我的表结构是:-- Create table
create table DEMON.BBS
(
  BBSID INTEGER not null,
  USERNAME VARCHAR2(20),
  TITLE VARCHAR2(20),
  IP CHAR(15),
  REPLYCONT INTEGER,
  REPLYUSERNAME VARCHAR2(20),
  CREATETIME DATE,
  LASTREPLYTIME DATE
)
tablespace LASTDANCE
  pctfree 10
  initrans 1
  maxtrans 255
  storage
  (
  initial 64
  minextents 1
  maxextents unlimited
  );
-- Create/Recreate primary, unique and foreign key constraints 
alter table DEMON.BBS
  add constraint BID primary key (BBSID)
  using index 
  tablespace LIGHT
  pctfree 10
  initrans 2
  maxtrans 255
  storage
  (
  initial 64K
  minextents 1
  maxextents unlimited
  );
dao代码:就bbsid 没有被set
Bbs bbs=new Bbs();
bbs.setUsername(username);
bbs.setTitle(title);
bbs.setReplyusername(replyusername);
bbs.setReplycont(replycont);
bbs.setLastreplytime(lastreplytime);
bbs.setIp(ip);
bbs.setCreatetime(createtime);
bbsdao.save(bbs);


[解决办法]
1.确认创建的序列是否正确
2.确认hibernate和创建表的位置在同一用户下
3.确认hibernate能连接上数据库
4.经过以上步骤,肯定木有问题

热点排行