-->
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.  [ 1 post ] 
Author Message
 Post subject: Optimized databse access with Criteria JOIN
PostPosted: Tue Nov 11, 2008 3:19 am 
Newbie

Joined: Tue Nov 11, 2008 3:00 am
Posts: 1
Dear Sirs,

i would like to accelerate my little web application,
when it loads some data in to a html table.
The table does not exactly match with a table on
the database. On the html-Pagetable there are
two or three additional columns, that needs to
be filled with data.

In order to prevent the application to create
an individual select for each line to get the
other data, i recognized the Criteria db access
as an way, to the dataload with one SQL JOIN
operation.

Code:
final Criteria  myCrit = curSession.createCriteria(Table1Impl.class)
      .createAlias("partList", "pPList", CriteriaSpecification.INNER_JOIN)
      .setFetchMode("pPList", FetchMode.JOIN)
      .addOrder( Order.asc("pr1") )
      .addOrder( Order.asc("pPList.pr2") );

final List<Property> dbRes = (List<Property>)
      myCrit.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY).list() ;


That was my solution. In the log i noticed the
creation of the SQL command i was exprected.
The DISTINCT_ROOT_ENTITY kicked out any
multiple occurence of data, also perfect.

But when the HTML-List Kode started, i saw (again)
a mass of simple SQL accesses on partList,
by calling .getPartList((). I thought HIBERNATE
has the data in his cache ???

Did i forget to configure something or shall i
better load the data in a different way ?

Thank you for your support!
Groovy


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.