ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Clinton Begin <clinton.be...@gmail.com>
Subject Re: ResultHandler - OutOfMemory Exception
Date Mon, 14 Sep 2009 23:24:26 GMT
The nestedResultObjects is necessary for join mapping.  One way to deal with
this though, is to use batches of reads as well as writes.  Use the
pagination facilities and possibly even the proprietary offset/limit
features of your database to grab subsets of the results.
Incidentally I'm rewriting the DefaultResultSetHandler to be easier to
understand.  But I don't see the need for that cache going away anytime
soon...

Clinton

On Mon, Sep 14, 2009 at 1:47 PM, K. Arnold <akarnold@comcast.net> wrote:

>
> I am trying to iterate over a result set of 2million records, for a large
> bulk load and transformation into a new ODS.  It appears that I am getting
> an OutOfMemoryException because the DefaultResultSetHandler is caching the
> object in the nestedResultObjects property.  Is there some property I
> should
> set or statement/ method call I should be using that will allow me to
> process one line at a time and not have the nestedResultObjects store each
> object?
>
> My goal:
> * Grab a row
> * Send it to be processed
> * Once processed, move on to the next row.
> Note: Once a row is processed I no longer need a tie back to the object.
>
>
>
> I have included the custom ResultHandler, the unit test and the
> configuration file.  Please let me know if you need other information.
>
> package com.primetherapeutics.benplanmgr.entity.rxclaim;
>
> import org.apache.ibatis.executor.result.ResultContext;
> import org.apache.ibatis.executor.result.ResultHandler;
> import org.apache.log4j.Logger;
>
> /**
>  * @author kjarnold
>  *
>  */
> public class GroupEligibilityResultHandler implements ResultHandler {
>        Logger logger =
> Logger.getLogger(GroupEligibilityResultHandler.class);
>
>        int count = 0;
>
>        public void handleResult(ResultContext context) {
>                if(context.getResultObject() != null) {
>                        count++;
>                        logger.debug(count);
>                }
>                //context.stop();
>        }
>
>        public int getCount() {
>                return count;
>        }
>
> }
>
>        @Test
>        public void getGroupElibibilitiesByResultHandler() {
>                Map<String, String> parameterMap = new HashMap<String,
> String>();
>                parameterMap.put("gelThruDate", "1090101");
>                parameterMap.put("addDate", "1090911");
>                parameterMap.put("chgDate", "1090911");
>                parameterMap.put("planDate", "1090101");
>                try {
>                        GroupEligibilityResultHandler handler = new
> GroupEligibilityResultHandler();
>
>
> session.select("com.primetherapeutics.benplanmgr.entity.rxclaim.data.GroupEligibilityMapper.getGroupEligibilities",
>                                        parameterMap, handler);
>                        logger.debug(handler.getCount());
>
>                } finally {
>                        session.close();
>                }
>
>        }
>
>
> Here are my mapping files:
>
> <?xml version="1.0" encoding="UTF-8" ?>
> <!DOCTYPE configuration PUBLIC "-//ibatis.apache.org//DTD Config 3.0//EN"
>        "http://ibatis.apache.org/dtd/ibatis-3-config.dtd">
> <configuration>
> <settings>
>        <setting name="multipleResultSetsEnabled" value="false"/>
>        <setting name="defaultExecutorType" value="BATCH"/>
> </settings>
>        <mappers>
>                <mapper
>
> resource="com/primetherapeutics/benplanmgr/entity/rxclaim/data/BenefitMaxSchedule.xml"/>
>                <mapper
>
> resource="com/primetherapeutics/benplanmgr/entity/rxclaim/data/GroupEligibility.xml"/>
>        </mappers>
> </configuration>
>
>
>
> --
> View this message in context:
> http://www.nabble.com/ResultHandler---OutOfMemory-Exception-tp25442025p25442025.html
> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
> For additional commands, e-mail: user-java-help@ibatis.apache.org
>
>

Mime
View raw message