- This topic has 4 replies, 3 voices, and was last updated 19 years, 9 months ago by Sebastian Dieguez.
-
AuthorPosts
-
RUFFIEMemberHere I am again with another question.
I’m using an Oracle database now and for ID generation I am mapping my tables with the sequence generation.This is my code of one of my tables named Component:
<hibernate-mapping package="com.frontier.hibernate"> <class name="Component" table="COMPONENT"> <id name="idComponent" column="ID_COMPONENT" type="java.lang.Long"> <generator class="sequence"> <param name="sequence">id_component_sequence</param> </generator> </id> <property name="cdComponent" column="CD_COMPONENT" type="java.lang.String" not-null="true" /> etc...etc...
When I try a simple INSERT (throug a form on a jsp page) i get an error as in “could not save object”.
So i looked at my Tomcat log and it gave me this:2004-10-26 09:48:48 StandardWrapperValve[action]: Servlet.service() for servlet action threw exception java.lang.RuntimeException: net.sf.hibernate.JDBCException: Could not save object at com.frontier.hibernate.ComponentService.addComponent(ComponentService.java:260) at com.frontier.action.AddComponent.execute(AddComponent.java:54) at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484) at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482) at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525) at javax.servlet.http.HttpServlet.service(HttpServlet.java:709) at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520) at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929) at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705) at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683) at java.lang.Thread.run(Unknown Source) Caused by: net.sf.hibernate.JDBCException: Could not save object at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:776) at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:731) at com.frontier.hibernate.ComponentService.addComponent(ComponentService.java:254) ... 31 more [b]Caused by: java.sql.SQLException: ORA-02289: sequence does not exist at oracle.jdbc.dbaccess.DBError.throwSqlException[/b](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 net.sf.hibernate.id.SequenceGenerator.generate(SequenceGenerator.java:69) at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:758)
As you can see there is something about a sequence not being found. I have absolutely no idea what to do with that, cuz Oracle is also new for me, but I’ve read other forums also and my mapping file should be correct they say.
I’m using the Oracle 9 release 2 JDBC driver (ojdbc14.zip).
So any idea what to with this?Also since I’m using MyEclipse i would like to ask where i can set the hibernate properties. I wanna enable hibernate debuggin and set this property “hibernate.show_sql=true” in hibernate.properties. I’ve read somewhere that this can give a somewhat more detailed debugging output e.g. sql statement erros and such.
Riyad KallaMemberThis is why god invented searching:
http://forum.hibernate.org/viewtopic.php?t=933283&highlight=ora02289
http://forum.hibernate.org/viewtopic.php?t=930058&highlight=ora02289
http://forum.hibernate.org/viewtopic.php?t=496&highlight=ora02289I wanna enable hibernate debuggin and set this property “hibernate.show_sql=true” in hibernate.properties.
This can also be set in the hibernate.cfg.xml file that MyEclipse generates.
http://www.hibernate.org/hib_docs/reference/en/html/session-configuration.html#configuration-xmlconfig
RUFFIEMemberHmm I must be stupid or something, cause like on the hibernate forums i searched on sequence exist, but i overlooked the search link on the forum page and used the advanced search on the topmenu of the myeclipse page 😳 And that gave me nothing.
So i’m sorry, i usually do search, tnx for the reply.
Riyad KallaMemberSo i’m sorry, i usually do search, tnx for the reply.
No problem, it just sounded like a very hibernatey question to me so I figured they’d know better than I would.
Sebastian DieguezMemberPosibly is that another hbm.xml generated by MyEclipse you didn’t set the name of the sequence, this is often becouse MyEclipse DOESN’T provide a text field to input the sequence name to make the tag:
<generator class="sequence"> <param name="sequence">id_component_sequence</param> </generator>
So you have to edit the xml by hand.
This and having to save the ERD each time are the major drawbacks of the DB Explorer. -
AuthorPosts