Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
[b]Hibernate version:3.0[/b]
[b]Mapping documents:
<session-factory>
<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hibernate.connection.url">jdbc:oracle:thin:@XXXX:project</property>
<property name="hibernate.connection.username">scott</property>
<property name="hibernate.connection.password">tiger</property>
<property name="hibernate.connection.pool_size">10</property>
<property name="show_sql">true</property>
<property name="dialect">org.hibernate.dialect.Oracle9Dialect</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<!-- Mapping files -->
<mapping resource="player.hbm.xml"/>
</session-factory>
[/b]
[b] Session session = factory.openSession();
Transaction txShow = session.beginTransaction();
player p1=new player();
String query2 = " SELECT {t1}.ID as {t1.id} , {t1}.NAME as {t1.name} FROM PLAYERTABLE t1 where rownum < 20 MINUS select {t1}.ID as {t1.id} ,{t1}.NAME as {t1.name} FROM PLAYERTABLE t1 where rownum < 10 " ;
List l = session.createSQLQuery(query2)
.addEntity("t1", player.class)
.list();
out.println("Show Starts-----2---Length+"+l.size());
txShow.commit();
session.flush();
session.close();
[/b]
[b]Full stack trace of any exception that occurs:
org.hibernate.exception.GenericJDBCException: could not execute query org.hibernate.exception.GenericJDBCException: could not execute query at org.hibernate.exception.ErrorCodeConverter.handledNonSpecificException(ErrorCodeConverter.java:92) at org.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:80) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43) at org.hibernate.loader.Loader.doList(Loader.java:1596) at org.hibernate.loader.Loader.list(Loader.java:1577) at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:112) at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1414) at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:153) at hiberservlet.doPost(hiberservlet.java:166) at javax.servlet.http.HttpServlet.service(HttpServlet.java:760) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2422) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643) at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:163) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:199) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:828) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:700) at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:584) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683) at java.lang.Thread.run(Thread.java:536) Caused by: java.sql.SQLException: No more data to read from socket at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134) at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179) at oracle.jdbc.dbaccess.DBError.check_error(DBError.java:1160) at oracle.jdbc.ttc7.MAREngine.unmarshalUB1(MAREngine.java:963) at oracle.jdbc.ttc7.MAREngine.unmarshalSB1(MAREngine.java:893) at oracle.jdbc.ttc7.Oclose.receive(Oclose.java:101) at oracle.jdbc.ttc7.TTC7Protocol.close(TTC7Protocol.java:720) at oracle.jdbc.driver.OracleStatement.close(OracleStatement.java:717) at oracle.jdbc.driver.OraclePreparedStatement.privateClose(OraclePreparedStatement.java:489) at oracle.jdbc.driver.OraclePreparedStatement.close(OraclePreparedStatement.java:396) at org.hibernate.jdbc.AbstractBatcher.closePreparedStatement(AbstractBatcher.java:417) at org.hibernate.jdbc.AbstractBatcher.closeStatement(AbstractBatcher.java:197) at org.hibernate.jdbc.AbstractBatcher.closeQueryStatement(AbstractBatcher.java:213) at org.hibernate.jdbc.AbstractBatcher.closeQueryStatement(AbstractBatcher.java:143) at org.hibernate.loader.Loader.getResultSet(Loader.java:1281) at org.hibernate.loader.Loader.doQuery(Loader.java:391) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:218) at org.hibernate.loader.Loader.doList(Loader.java:1593) ... 36 more
[/b]
[b]Name and version of the database you are using:oracle9i[/b]
[b]The generated SQL (show_sql=true): in Tomcat4.1 console the error is as
Hibernate: SELECT t1.ID as ID0_ , t1.NAME as name0_0_ FROM PLAYERTABLE t1 where
rownum < 20 MINUS select t1.ID as ID0_ ,t1.NAME as name0_0_ FROM PLAYERTABLE t1 where rownum < 10
2006-08-29 18:39:11,759 WARN [org.hibernate.util.JDBCExceptionReporter] - SQL Error: 17410, SQLState: null>
2006-08-29 18:39:11,759 ERROR [org.hibernate.util.JDBCExceptionReporter] - No more data to read from socket>
[/b]
[b] if i will use simple session.createQuery(
" FROM player where rownum < 20 minus FROM player where rownum < 10 " ).list();
the error is you can not use MINUS in the query .
[/b]
So how to execute the above query using minus and rownum .Please help me to workout above problem .
[b][/b]