By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,533 Members | 1,497 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,533 IT Pros & Developers. It's quick & easy.

Hibernate

P: 2
Hi

Already my application in Struts using JDBC.At present my application is implemented in Struts with hibernate
So i am not changing the SQL queries converting to the like this

String sql4="select max(sed.SubexpenseId) from hiber.SubexpenseDet sed";
List query1 = session.createSQLQuery(sql4).addEntity(SubexpenseD et.class).list();
Iterator it1 = query1.iterator();
it1.hasNext();
SubexpenseDet set1 = (SubexpenseDet) it1.next();
subexpenseid=set1.getSubexpenseId();


at the retriving time i got the Exception like this

Hibernate: select max(sed.SubexpenseId) from hiber.SubexpenseDet sed
org.hibernate.exception.SQLGrammarException: could not execute query
at org.hibernate.exception.SQLStateConverter.convert( SQLStateConverte
ava:67)
at org.hibernate.exception.JDBCExceptionHelper.conver t(JDBCExceptionH
er.java:43)
at org.hibernate.loader.Loader.doList(Loader.java:214 8)
at org.hibernate.loader.Loader.listIgnoreQueryCache(L oader.java:2029)
at org.hibernate.loader.Loader.list(Loader.java:2024)
at org.hibernate.loader.custom.CustomLoader.list(Cust omLoader.java:11
at org.hibernate.impl.SessionImpl.listCustomQuery(Ses sionImpl.java:16

at org.hibernate.impl.AbstractSessionImpl.list(Abstra ctSessionImpl.ja
142)
at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl. java:164)
at food.FoodDAO.insertBreakFastData(FoodDAO.java:111)
at food.FoodAction.execute(FoodAction.java:57)
at org.apache.struts.action.RequestProcessor.processA ctionPerform(Req
tProcessor.java:431)
at org.apache.struts.action.RequestProcessor.process( RequestProcessor
va:236)
at org.apache.struts.action.ActionServlet.process(Act ionServlet.java:
6)
at org.apache.struts.action.ActionServlet.doPost(Acti onServlet.java:4

at javax.servlet.http.HttpServlet.service(HttpServlet .java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:802)
at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(A
icationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.do Filter(Applicati
ilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapp
alve.java:213)
at org.apache.catalina.core.StandardContextValve.invo ke(StandardConte
alve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValv
ava:126)
at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValv
ava:105)
at org.apache.catalina.core.StandardEngineValve.invok e(StandardEngine
ve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.servic e(CoyoteAdapter.
a:148)
at org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.j
:856)
at org.apache.coyote.http11.Http11Protocol$Http11Conn ectionHandler.pr
ssConnection(Http11Protocol.java:744)
at org.apache.tomcat.util.net.PoolTcpEndpoint.process Socket(PoolTcpEn
int.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThr ead.runIt(Leader
lowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlR unnable.run(Thre
ool.java:684)
at java.lang.Thread.run(Unknown Source)
Caused by: com.mysql.jdbc.exceptions.MySQLSyntaxErrorExceptio n: Table 'hiber.
expensedet' doesn't exist
at com.mysql.jdbc.SQLError.createSQLException(SQLErro r.java:936)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.ja va:2870)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:15 73)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java :1665)
at com.mysql.jdbc.Connection.execSQL(Connection.java: 3176)
at com.mysql.jdbc.PreparedStatement.executeInternal(P reparedStatement
va:1153)
at com.mysql.jdbc.PreparedStatement.executeQuery(Prep aredStatement.ja
1266)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(Ab stractBatcher.ja
139)
at org.hibernate.loader.Loader.getResultSet(Loader.ja va:1669)
at org.hibernate.loader.Loader.doQuery(Loader.java:66 2)
at org.hibernate.loader.Loader.doQueryAndInitializeNo nLazyCollections
ader.java:224)
at org.hibernate.loader.Loader.doList(Loader.java:214 5)
... 28 more


what is the problem in my sql query and the code

please help me

thank u
Jun 26 '07 #1
Share this Question
Share on Google+
1 Reply


10K+
P: 13,264
Please do not post questions in the articles section.
Moved to the forum.
Jun 26 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.