-->
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.  [ 4 posts ] 
Author Message
 Post subject: Named Native Query getting modified in Hibernate3
PostPosted: Thu Dec 10, 2009 7:56 am 
Newbie

Joined: Thu Dec 10, 2009 7:43 am
Posts: 2
I am using a workload with the annotated NamedNativeQuery used in one of the source files as:
Code:
@NamedNativeQueries({
    @NamedNativeQuery(name="quoteejb.quoteForUpdate", query="select * from quoteejb q where q.symbol=? for update",resultClass=org.apache.geronimo.samples.daytrader.QuoteDataBean.class)
})


When I run this app using Hibernate 3.2.6 jars, it goes through fine with the query during run as:

select * from quoteejb q where q.symbol=? for update

But with Hibernate 3.3 jar, it modifies the query as following (using show_sql = true)
select * from ( select rownumber() over() as rownumber_, * from quoteejb q1 where q1.symbol=? for update ) as temp_ where rownumber_ <= ?

It breaks down immediately after this SQL display and throws exception mentioned below.Why is the native query getting modified? Is it some bug in Hibernate 3.3?
Thanks.

Code:
[size=75] E org.apache.geronimo.samples.daytrader.util.Log error Error: TradeAction:updateQuotePrice --
   javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query
[12/10/09 16:27:31:390 IST] 000000ee SystemOut     O javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query
[12/10/09 16:27:31:390 IST] 000000ee SystemOut     O    at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:614)
[12/10/09 16:27:31:390 IST] 000000ee SystemOut     O    at org.hibernate.ejb.QueryImpl.getSingleResult(QueryImpl.java:128)
[12/10/09 16:27:31:390 IST] 000000ee SystemOut     O    at org.apache.geronimo.samples.daytrader.ejb3.TradeSLSBBean.updateQuotePriceVolume(TradeSLSBBean.java:411)
[12/10/09 16:27:31:390 IST] 000000ee SystemOut     O    at org.apache.geronimo.samples.daytrader.ejb3.EJSRemote0SLTradeSLSBBean_8ae41722.updateQuotePriceVolume(EJSRemote0SLTradeSLSBBean_8ae41722.java)
[12/10/09 16:27:31:390 IST] 000000ee SystemOut     O    at org.apache.geronimo.samples.daytrader.ejb3._TradeSLSBRemote_Stub.updateQuotePriceVolume(_TradeSLSBRemote_Stub.java)
[12/10/09 16:27:31:390 IST] 000000ee SystemOut     O    at org.apache.geronimo.samples.daytrader.TradeAction.updateQuotePriceVolume(TradeAction.java:326)
[12/10/09 16:27:31:390 IST] 000000ee SystemOut     O    at org.apache.geronimo.samples.daytrader.TradeAction.buy(TradeAction.java:139)
[12/10/09 16:27:31:390 IST] 000000ee SystemOut     O    at org.apache.geronimo.samples.daytrader.web.TradeServletAction.doBuy(TradeServletAction.java:225)
[12/10/09 16:27:31:390 IST] 000000ee SystemOut     O    at org.apache.geronimo.samples.daytrader.web.TradeAppServlet.performTask(TradeAppServlet.java:159)
[12/10/09 16:27:31:390 IST] 000000ee SystemOut     O    at org.apache.geronimo.samples.daytrader.web.TradeAppServlet.doGet(TradeAppServlet.java:77)
[12/10/09 16:27:31:390 IST] 000000ee SystemOut     O    at javax.servlet.http.HttpServlet.service(HttpServlet.java:718)
[12/10/09 16:27:31:390 IST] 000000ee SystemOut     O    at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
[12/10/09 16:27:31:390 IST] 000000ee SystemOut     O    at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1530)
[12/10/09 16:27:31:390 IST] 000000ee SystemOut     O    at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:829)
[12/10/09 16:27:31:390 IST] 000000ee SystemOut     O    at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:458)
[12/10/09 16:27:31:390 IST] 000000ee SystemOut     O    at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:175)
[12/10/09 16:27:31:390 IST] 000000ee SystemOut     O    at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:91)
[12/10/09 16:27:31:390 IST] 000000ee SystemOut     O    at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:862)
[12/10/09 16:27:31:390 IST] 000000ee SystemOut     O    at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1583)
[12/10/09 16:27:31:390 IST] 000000ee SystemOut     O    at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:178)
[12/10/09 16:27:31:390 IST] 000000ee SystemOut     O    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:455)
[12/10/09 16:27:31:390 IST] 000000ee SystemOut     O    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:384)
[12/10/09 16:27:31:390 IST] 000000ee SystemOut     O    at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:83)
[12/10/09 16:27:31:390 IST] 000000ee SystemOut     O    at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
[12/10/09 16:27:31:390 IST] 000000ee SystemOut     O    at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
[12/10/09 16:27:31:390 IST] 000000ee SystemOut     O    at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
[12/10/09 16:27:31:390 IST] 000000ee SystemOut     O    at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
[12/10/09 16:27:31:390 IST] 000000ee SystemOut     O    at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
[12/10/09 16:27:31:390 IST] 000000ee SystemOut     O    at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
[12/10/09 16:27:31:390 IST] 000000ee SystemOut     O    at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
[12/10/09 16:27:31:390 IST] 000000ee SystemOut     O    at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1550)
[12/10/09 16:27:31:390 IST] 000000ee SystemOut     O Caused by: org.hibernate.exception.SQLGrammarException: could not execute query
[12/10/09 16:27:31:390 IST] 000000ee SystemOut     O    at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:90)
[12/10/09 16:27:31:390 IST] 000000ee SystemOut     O    at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
[12/10/09 16:27:31:390 IST] 000000ee SystemOut     O    at org.hibernate.loader.Loader.doList(Loader.java:2231)
[12/10/09 16:27:31:390 IST] 000000ee SystemOut     O    at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2125)
[12/10/09 16:27:31:390 IST] 000000ee SystemOut     O    at org.hibernate.loader.Loader.list(Loader.java:2120)
[12/10/09 16:27:31:390 IST] 000000ee SystemOut     O    at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:312)
[12/10/09 16:27:31:390 IST] 000000ee SystemOut     O    at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1722)
[12/10/09 16:27:31:390 IST] 000000ee SystemOut     O    at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:165)
[12/10/09 16:27:31:390 IST] 000000ee SystemOut     O    at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:175)
[12/10/09 16:27:31:390 IST] 000000ee SystemOut     O    at org.hibernate.ejb.QueryImpl.getSingleResult(QueryImpl.java:88)
[12/10/09 16:27:31:390 IST] 000000ee SystemOut     O    ... 29 more
[12/10/09 16:27:31:390 IST] 000000ee SystemOut     O Caused by: com.ibm.db2.jcc.am.jo: DB2 SQL Error: SQLCODE=-104, SQLSTATE=42601, SQLERRMC=*;ver() as rownumber_,;<select_sublist>, DRIVER=3.57.109
[12/10/09 16:27:31:390 IST] 000000ee SystemOut     O    at com.ibm.db2.jcc.am.bd.a(bd.java:676)
[12/10/09 16:27:31:390 IST] 000000ee SystemOut     O    at com.ibm.db2.jcc.am.bd.a(bd.java:60)
[12/10/09 16:27:31:390 IST] 000000ee SystemOut     O    at com.ibm.db2.jcc.am.bd.a(bd.java:127)
[12/10/09 16:27:31:390 IST] 000000ee SystemOut     O    at com.ibm.db2.jcc.am.lm.c(lm.java:2506)
[12/10/09 16:27:31:390 IST] 000000ee SystemOut     O    at com.ibm.db2.jcc.am.lm.d(lm.java:2483)
[12/10/09 16:27:31:390 IST] 000000ee SystemOut     O    at com.ibm.db2.jcc.am.lm.a(lm.java:1963)
[12/10/09 16:27:31:390 IST] 000000ee SystemOut     O    at com.ibm.db2.jcc.t4.db.g(db.java:139)
[12/10/09 16:27:31:390 IST] 000000ee SystemOut     O    at com.ibm.db2.jcc.t4.db.a(db.java:39)
[12/10/09 16:27:31:390 IST] 000000ee SystemOut     O    at com.ibm.db2.jcc.t4.t.a(t.java:32)
[12/10/09 16:27:31:390 IST] 000000ee SystemOut     O    at com.ibm.db2.jcc.t4.sb.i(sb.java:135)
[12/10/09 16:27:31:390 IST] 000000ee SystemOut     O    at com.ibm.db2.jcc.am.lm.eb(lm.java:1934)
[12/10/09 16:27:31:390 IST] 000000ee SystemOut     O    at com.ibm.db2.jcc.am.mm.hc(mm.java:2803)
[12/10/09 16:27:31:390 IST] 000000ee SystemOut     O    at com.ibm.db2.jcc.am.mm.b(mm.java:3522)
[12/10/09 16:27:31:390 IST] 000000ee SystemOut     O    at com.ibm.db2.jcc.am.mm.Ub(mm.java:651)
[12/10/09 16:27:31:390 IST] 000000ee SystemOut     O    at com.ibm.db2.jcc.am.mm.executeQuery(mm.java:625)
[12/10/09 16:27:31:390 IST] 000000ee SystemOut     O    at com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement.pmiExecuteQuery(WSJdbcPreparedStatement.java:1086)
[12/10/09 16:27:31:390 IST] 000000ee SystemOut     O    at com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement.executeQuery(WSJdbcPreparedStatement.java:707)
[12/10/09 16:27:31:390 IST] 000000ee SystemOut     O    at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:208)
[12/10/09 16:27:31:390 IST] 000000ee SystemOut     O    at org.hibernate.loader.Loader.getResultSet(Loader.java:1808)
[12/10/09 16:27:31:390 IST] 000000ee SystemOut     O    at org.hibernate.loader.Loader.doQuery(Loader.java:697)
[12/10/09 16:27:31:390 IST] 000000ee SystemOut     O    at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)
[12/10/09 16:27:31:406 IST] 000000ee SystemOut     O    at org.hibernate.loader.Loader.doList(Loader.java:2228)
[12/10/09 16:27:31:406 IST] 000000ee SystemOut     O    ... 36 more[/size]


Top
 Profile  
 
 Post subject: Re: Named Native Query getting modified in Hibernate3
PostPosted: Thu Mar 18, 2010 2:12 pm 
Newbie

Joined: Thu Jul 17, 2008 10:27 am
Posts: 5
Hi prat0318,

I have a similar problem to yours. In my NamedNativeQuery are the placeholders not replaced.
And it looks like your problem.

Could you fix your problem? And it would be nice if you could tell me how.

Greetings,
arres


Top
 Profile  
 
 Post subject: Re: Named Native Query getting modified in Hibernate3
PostPosted: Sat Mar 20, 2010 12:37 pm 
Newbie

Joined: Thu Dec 10, 2009 7:43 am
Posts: 2
No .... we then used the old hibernate version 3.2 i guess ... and worked with that.


Top
 Profile  
 
 Post subject: Re: Named Native Query getting modified in Hibernate3
PostPosted: Mon Mar 22, 2010 6:38 am 
Newbie

Joined: Thu Jul 17, 2008 10:27 am
Posts: 5
Hmmm :(
But thanks for your reply.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.