Hibernate version: 3.3.0.cr1
Name and version of the database you are using: MySQL 5.0.42
The problem I seem to be having is that the scrollableresults are not querying the database using limits.
My resultset to be returned will be huge. I'm trying to use the scrollableresults as follows:
Code:
Query aq = sess.createSQLQuery("SELECT file_type, definition, keywords, comment, feature_name, value from rsp r inner join rsp_child rc on r.idd = rc.idd").setCacheMode(CacheMode.IGNORE).setReadOnly(true).setFetchSize(50);
ScrollableResults aaa = aq.scroll(ScrollMode.FORWARD_ONLY);
The stack trace when it pops, which is on the ScrollableResults aaa ... line :
Code:
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.myco.util.Run.main(Run.java:24)
Caused by: java.lang.OutOfMemoryError: Java heap space
at com.mysql.jdbc.Buffer.<init>(Buffer.java:58)
at com.mysql.jdbc.MysqlIO.nextRow(MysqlIO.java:1441)
at com.mysql.jdbc.MysqlIO.readSingleRowSet(MysqlIO.java:2816)
at com.mysql.jdbc.MysqlIO.getResultSet(MysqlIO.java:467)
at com.mysql.jdbc.MysqlIO.readResultsForQueryOrUpdate(MysqlIO.java:2510)
at com.mysql.jdbc.MysqlIO.readAllResults(MysqlIO.java:1746)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2135)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2542)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1734)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1885)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:184)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1785)
at org.hibernate.loader.Loader.scroll(Loader.java:2278)
at org.hibernate.loader.custom.CustomLoader.scroll(CustomLoader.java:295)
at org.hibernate.impl.StatelessSessionImpl.scrollCustomQuery(StatelessSessionImpl.java:580)
at org.hibernate.impl.AbstractSessionImpl.scroll(AbstractSessionImpl.java:147)
at org.hibernate.impl.SQLQueryImpl.scroll(SQLQueryImpl.java:178)
at com.myco
When I look at the process list inside of mysql, I notice that the query has no limit. It's just a select for all items.
So I assume I have a problem in my hibernate.cfg.xml file. This is what I have in my hibernate.cfg.xml file:
Code:
<hibernate-configuration>
<session-factory name="java:hibernate/SessionFactory">
<property name="dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.username">u</property>
<property name="connection.password">p</property>
<property name="connection.url">
<![CDATA[jdbc:mysql://localhost:3306/mydb]]>
</property>
<property name="show_sql">false</property>
<property name="use_outer_join">true</property>
<property name="jdbc.batch_size">30</property>
<property name="hibernate.jdbc.fetch_size">30</property>
<property name="connection.isolation">2</property>
<property name="hibernate.jdbc.use_scrollable_resultset">true</property>
<property name="hibernate.jdbc.batch_size">35</property>
<property name="c3p0.min_size">5</property>
<property name="c3p0.max_size">25</property>
<property name="c3p0.timeout">30</property>
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
<property name="cache.use_query_cache">false</property>
<property name="cache.use_minimal_puts">false</property>
<property name="max_fetch_depth">3</property>
</session-factory>
</hibernate-configuration>
So I guess what I would love to know is what sort of setup parameter I may be missing, or setting incorrectly. I just need to be able to loop through an enormous set of data for processing.
Any help would be awesome!
Thanks,
Jeff