This week's book giveaway is in the General Computing forum.
We're giving away four copies of Emmy in the Key of Code and have Aimee Lucido on-line!
See this thread for details.
Win a copy of Emmy in the Key of Code this week in the General Computing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

Hibenate & Oracle 10g

 
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello
I am facing some problem in setting the primary key value in database.

I am using Oracel10g as my DB and front end is JSP,struts and using hibenate.In customer.hbm.xml I have mention the primary key i.e customerID as

<
class name="gov.kda.JRECS.Customer.DAO.Customer " table="CUSTOMER" schema ="JRECS">
<id name="customerId" type="java.lang.Long">
<column name="CUSTOMER_ID" precision="6" scale= "0" />
<generator class="native" >
</generator>
</id>

But when ever I try to set it shows me an error :

13:57:29,640 INFO [STDOUT] 13:57:29,640 ERROR [CustomerDAO] save failed
org.hibernate.exception.SQLGrammarException
: could not get next sequence value
at org.hibernate.exception.SQLStateConverter.convert(
SQLStateConverter.java:67)
at org.hibernate.exception.JDBCExceptionHelper.convert(
JDBCExceptionHelper.java:43)
at org.hibernate.id.SequenceGenerator.generate(
SequenceGenerator.java:96)
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 gov.kda.JRECS.Customer.DAO.CustomerDAO.save(
CustomerDAO.java:37)
at gov.kda.JRECS.Customer.struts.Action.CustomerAction.execute(
CustomerAction.java:79)
at org.apache.struts.action.RequestProcessor.processActionPerform(
RequestProcessor.java:419)
at org.apache.struts.action.RequestProcessor.process(
RequestProcessor.java:224)
at org.apache.struts.action.ActionServlet.process(
ActionServlet.java:1194)
at org.apache.struts.action.ActionServlet.doPost(
ActionServlet.java:432)
at javax.servlet.http.HttpServlet.service(
HttpServlet.java:710)
at javax.servlet.http.HttpServlet.service(
HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(
ApplicationFilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(
ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(
ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(
StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.invoke(
StandardContextValve.java:175)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(
SecurityAssociationValve.java:179)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(
JaccContextValve.java:84)
at org.apache.catalina.core.StandardHostValve.invoke(
StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(
ErrorReportValve.java:104)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(
CachedConnectionValve.java:157)
at org.apache.catalina.core.StandardEngineValve.invoke(
StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(
CoyoteAdapter.java:241)
at org.apache.coyote.http11.Http11Processor.process(
Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(
Http11Protocol.java:580)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(
JIoEndpoint.java:447)
at java.lang.Thread.run(Unknown Source)
Caused by:
java.sql.SQLException: ORA-02289: sequence does not exist
at oracle.jdbc.driver.DatabaseError.throwSqlException(
DatabaseError.java:125)
at oracle.jdbc.driver.T4CTTIoer.processError(
T4CTTIoer.java:316)
at oracle.jdbc.driver.T4CTTIoer.processError(
T4CTTIoer.java:282)
at oracle.jdbc.driver.T4C8Oall.receive(
T4C8Oall.java:639)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(
T4CPreparedStatement.java:185)
at oracle.jdbc.driver.T4CPreparedStatement.execute_for_describe(
T4CPreparedStatement.java:503)
at oracle.jdbc.driver.OracleStatement.execute_maybe_describe(
OracleStatement.java:965)
at oracle.jdbc.driver.T4CPreparedStatement.execute_maybe_describe(
T4CPreparedStatement.java:535)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(
OracleStatement.java:1051)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(
OraclePreparedStatement.java:2984)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(
OraclePreparedStatement.java:3026)
at org.hibernate.id.SequenceGenerator.generate(
SequenceGenerator.java:75)
... 35 more
13:57:29,640 ERROR [STDERR]
org.hibernate.exception.SQLGrammarException: could not get next sequence value
at org.hibernate.exception.SQLStateConverter.convert(
SQLStateConverter.java:67)
at org.hibernate.exception.JDBCExceptionHelper.convert(
JDBCExceptionHelper.java:43)
at org.hibernate.id.SequenceGenerator.generate(
SequenceGenerator.java:96)
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 gov.kda.JRECS.Customer.DAO.CustomerDAO.save(
CustomerDAO.java:37)
at gov.kda.JRECS.Customer.struts.Action.CustomerAction.execute(
CustomerAction.java:79)
at org.apache.struts.action.RequestProcessor.processActionPerform(
RequestProcessor.java:419)
at org.apache.struts.action.RequestProcessor.process(
RequestProcessor.java:224)
at org.apache.struts.action.ActionServlet.process(
ActionServlet.java:1194)
at org.apache.struts.action.ActionServlet.doPost(
ActionServlet.java:432)
at javax.servlet.http.HttpServlet.service(
HttpServlet.java:710)
at javax.servlet.http.HttpServlet.service(
HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(
ApplicationFilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(
ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(
ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(
StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.invoke(
StandardContextValve.java:175)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(
SecurityAssociationValve.java:179)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(
JaccContextValve.java:84)
at org.apache.catalina.core.StandardHostValve.invoke(
StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(
ErrorReportValve.java:104)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(
CachedConnectionValve.java:157)
at org.apache.catalina.core.StandardEngineValve.invoke(
StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(
CoyoteAdapter.java:241)
at org.apache.coyote.http11.Http11Processor.process(
Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(
Http11Protocol.java:580)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(
JIoEndpoint.java:447)
at java.lang.Thread.run(Unknown Source)
Caused by:
java.sql.SQLException: ORA-02289: sequence does not exist
at oracle.jdbc.driver.DatabaseError.throwSqlException(
DatabaseError.java:125)
at oracle.jdbc.driver.T4CTTIoer.processError(
T4CTTIoer.java:316)
at oracle.jdbc.driver.T4CTTIoer.processError(
T4CTTIoer.java:282)
at oracle.jdbc.driver.T4C8Oall.receive(
T4C8Oall.java:639)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(
T4CPreparedStatement.java:185)
at oracle.jdbc.driver.T4CPreparedStatement.execute_for_describe(
T4CPreparedStatement.java:503)
at oracle.jdbc.driver.OracleStatement.execute_maybe_describe(
OracleStatement.java:965)
at oracle.jdbc.driver.T4CPreparedStatement.execute_maybe_describe(
T4CPreparedStatement.java:535)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(
OracleStatement.java:1051)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(
OraclePreparedStatement.java:2984)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(
OraclePreparedStatement.java:3026)
at org.hibernate.id.SequenceGenerator.generate(
SequenceGenerator.java:75)
... 35 more
13:57:29,656 INFO [STDOUT] could not get next sequence value
As I dont create a Table I dont know the name of generator.
Please help me to find where I did mistake.

Thanks!!
 
ranger
Posts: 17344
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So you have a sequence table that it is supposed to use. I think you have to specifically say what it is in your mapping.

Mark
 
divya sharma
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Thanks for the reply!!

Now, I have mention the name of the sequence as :

<generator class="sequence">
<param name="sequence">customer_id_seq</param>
</generator>

but still it's showing me same error.

Thanks
 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
are you created the customer_id_seq in your oracle database ?
 
I do some of my very best work in water. Like this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!