aspose file tools*
The moose likes Object Relational Mapping and the fly likes Hibenate & Oracle 10g Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibenate & Oracle 10g" Watch "Hibenate & Oracle 10g" New topic
Author

Hibenate & Oracle 10g

divya sharma
Ranch Hand

Joined: Jan 25, 2007
Posts: 87
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!!


Divya
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17257
    
    6

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


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
divya sharma
Ranch Hand

Joined: Jan 25, 2007
Posts: 87
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
ishan dave
Ranch Hand

Joined: Apr 16, 2007
Posts: 39
are you created the customer_id_seq in your oracle database ?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hibenate & Oracle 10g