-->
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: Design issue
PostPosted: Tue May 22, 2007 2:43 am 
Newbie

Joined: Tue May 22, 2007 2:31 am
Posts: 1
Location: delhi
Hi Everybody,

I have one question...

Suppose i have such a query that brings data on the based of 4 or 5 clasess.
some of the tables have huge data around 4 to 5 lacs.

When Application runs the hibenate query. it loads all entity classes and respective data and stores it in memory.. so this way, our application server gets the heap memory error becuse all data is stores in memory.


what i feel there would be some design problem from my side...
so i want your precious advice in this context


regards
chandra
infoaxon technology


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 22, 2007 7:24 am 
Senior
Senior

Joined: Sat Apr 21, 2007 11:01 pm
Posts: 144
Select only the data you need into a simple VO using "select new", you can pick and choose which colums you want to go into the VO.
Here's an example:
Code:
    @SuppressWarnings("unchecked")
    public List<AdvancedSearchSitesResultsVO> findResultsVOListBySiteBucket(int siteBucketId){
       String hql = "select new " + AdvancedSearchSitesResultsVO.class.getName() + "(\n"
                  + "    sbs.site.siteId,\n"
                  + "    sbs.site.siteRef,\n"
                  + "    sbs.site.siteName,\n"
                  + "    sbs.site.siteAdd1,\n"
                  + "    sbs.site.siteGroup.sgDesc,\n"
                  + "    sbs.site.tenancyType.tenancyType\n"
                  + ")"
                  + "from " + SiteBucketSite.class.getName() + " as sbs\n"
                  + "where sbs.siteBucket.id = " + siteBucketId;
       return (List<AdvancedSearchSitesResultsVO>)getHibernateTemplate().find(hql);
    }

the VO:
Code:
   public AdvancedSearchSitesResultsVO(
      Integer siteId,
      String siteRef,
      String siteName,
      String addr1,
      String siteGroup,
      String usageType
   ){
      this.siteId = siteId;
      this.siteRef = siteRef;
      this.siteName = siteName;
      this.addr1 = addr1;
      this.siteGroup = siteGroup;
      this.usageType = usageType;
   }

_________________
Everytime you get an answer to your question without giving credit; god kills a kitten. :(


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 22, 2007 9:23 am 
Expert
Expert

Joined: Fri Aug 19, 2005 2:11 pm
Posts: 628
Location: Cincinnati
expanding on what he said, only load the collections that you need when you need them. lazy="true" on all the relationships. and load them only when you need to display them.

_________________
Chris

If you were at work doing this voluntarily, imagine what you'd want to see to answer a question.


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.