-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Hib not calling sequence.nextval, calling function instead??
PostPosted: Wed Jul 22, 2009 5:28 pm 
Newbie

Joined: Wed Oct 29, 2008 4:30 pm
Posts: 4
I have a hibernate mapping with a sequence mapped like so:

<id name="key" column="TOOLKIT_KEY">
<generator class='sequence' />
</id>

The db has a HIBERNATE_SEQUENCE defined and I can insert rows using this sequence via sqlplus

In the output below, hibernate is trying to perform a function call instead of a select hibernate_sequence.nextval from dual which I would expect. What am I doing wrong here?

The logging when trying to perform an insert into the table is this:

17:11:43,079 TRACE [DefaultSaveOrUpdateEventListener] saving transient instance
17:11:43,079 DEBUG [AbstractBatcher] about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
17:11:43,079 DEBUG [SQL] call next value for hibernate_sequence
17:11:43,079 INFO [STDOUT] Hibernate: call next value for hibernate_sequence
17:11:43,079 TRACE [AbstractBatcher] preparing statement
17:11:43,219 DEBUG [AbstractBatcher] about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
17:11:43,219 TRACE [AbstractBatcher] closing statement
17:11:43,219 DEBUG [JDBCExceptionReporter] could not get next sequence value [call next value for hibernate_sequence]
java.sql.SQLException: ORA-06576: not a valid function or procedure name

at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:743)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:213)
at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:952)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1160)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3285)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3329)
at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeQuery(WrappedPreparedStatement.java:236)
at org.hibernate.id.SequenceGenerator.generate(SequenceGenerator.java:98)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:122)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:210)
at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:56)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:195)
at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:50)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:93)
at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:562)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:550)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:546)
at org.ncems.cis.toolkit.dao.PersistenceManager.saveObject(PersistenceManager.java:181)
at org.ncems.cis.toolkit.dao.ToolkitDAO.saveObject(ToolkitDAO.java:36)
at org.ncems.cis.toolkit.model.BaseRptToolkit.saveToolkit(BaseRptToolkit.java:119)
at org.ncems.cis.toolkit.model.BaseRptToolkit.modifyToolkit(BaseRptToolkit.java:72)
at org.ncems.cis.toolkit.controller.SaveAction.process(SaveAction.java:50)
at com.thotwave.pluglet.framework.PlugletImpl.process(PlugletImpl.java:335)
at com.thotwave.pluglet.framework.PFApplicationImpl.process(PFApplicationImpl.java:1040)
at com.thotwave.pluglet.framework.AbstractPFApplication.doProcess(AbstractPFApplication.java:1103)
at com.thotwave.pluglet.framework.PFApplicationServlet.doPost(PFApplicationServlet.java:253)
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.ncems.shared.controller.SessionUserStorageFilter.doFilter(SessionUserStorageFilter.java:30)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.displaytag.filter.ResponseOverrideFilter.doFilter(ResponseOverrideFilter.java:125)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.thotwave.pluglet.security.SecurityFilter.doFilter(SecurityFilter.java:177)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
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(Thread.java:595)
17:11:43,219 WARN [JDBCExceptionReporter] SQL Error: 6576, SQLState: 65000
17:11:43,219 ERROR [JDBCExceptionReporter] ORA-06576: not a valid function or procedure name


Top
 Profile  
 
 Post subject: Re: Hib not calling sequence.nextval, calling function instead??
PostPosted: Fri Jul 24, 2009 11:11 am 
Newbie

Joined: Fri Jul 24, 2009 11:06 am
Posts: 8
You are not passing the sequence name. Use a <param> construct to pass the sequence name


Top
 Profile  
 
 Post subject: Re: Hib not calling sequence.nextval, calling function instead??
PostPosted: Fri Jul 24, 2009 11:17 am 
Newbie

Joined: Wed Oct 29, 2008 4:30 pm
Posts: 4
Thanks for the reply, the db has a hibernate_sequence defined which hibernate uses by default if there is no sequence defined in the mapping.

The actual problem turned out to be an incorrect dialect in the hibernate.cfg.xml... Doh!

An external developer that previously worked on this project apparently utilized hsqldb as his db for unit tests and his local development and the build.xml would convert this dialect to oracle when deployed to test or prod. I was unaware of this until I finally went line by line through everything and the wrong dialect finally caught my eye.

Live and learn :o)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.