-->
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: ScrollableResults - OutOfMemory - Doesn't appear to scroll
PostPosted: Thu Jun 05, 2008 3:31 pm 
Newbie

Joined: Tue Aug 26, 2003 2:31 pm
Posts: 15
Location: San Diego, CA
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


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 06, 2008 6:22 pm 
Newbie

Joined: Tue Aug 26, 2003 2:31 pm
Posts: 15
Location: San Diego, CA
Turns out you can't use scrollable resltsets when you use a join. They will only work on single table select statements. That solved the problem by breaking apart my query into multiple queries of single tables and dealing with each individually.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 07, 2008 7:39 am 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
Thanks for the update. It's nice to see people post back when they solve a problem.

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


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.