-->
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.  [ 5 posts ] 
Author Message
 Post subject: Performance of ResultTransformer slower than iBatis
PostPosted: Tue Jan 09, 2007 5:48 pm 
Newbie

Joined: Tue Sep 02, 2003 4:52 pm
Posts: 5
I use a ResultTransformer to get an array of DTO objects:

Code:
        Session s = sf.openSession();
        Query q = s.createSQLQuery("select id, text1, text2, text3, text4 from content where id > 20000");
        q.setResultTransformer(new ContentResultTransformer());

        Object[] result = null;

        for(int i = 0; i < 3; i++) {
            long start = System.currentTimeMillis();
            result = q.list().toArray();
            System.out.println("Duration: " + (System.currentTimeMillis() - start));
        }


Code:
public class ContentResultTransformer implements ResultTransformer {
    private static final long serialVersionUID = -398323871415254099L;

    public Object transformTuple(Object[] arg0, String[] arg1) {
        ContentDTO contentDTO = new ContentDTO();
        contentDTO.setId(((Integer)arg0[0]).intValue());
        contentDTO.setText1((String)arg0[1]);
        contentDTO.setText2((String)arg0[2]);
        contentDTO.setText3((String)arg0[3]);
        contentDTO.setText4((String)arg0[4]);
        return contentDTO;
    }

    public List transformList(List arg0) {
        return arg0;
    }
}


This query returns 80000 objects, duration with Hibernate is between 3.7 and 4 seconds. When I do the same with iBatis, using the Hibernate connection:

Code:
        sqlMap.setUserConnection(s.connection());
        long start = System.currentTimeMillis();
        List contentDTOs = sqlMap.queryForList("getContent", new Integer(20000));
        result = (ContentDTO[]) contentDTOs.toArray(new ContentDTO[contentDTOs.size()]);
        System.out.println("Duration: " + (System.currentTimeMillis() - start));


and the SQL-Map

Code:
<sqlMap namespace="Content">
   <select id="getContent" resultClass="com.vector.easee.ormappertest.ContentDTO">
      SELECT
         id,
         text1,
         text2,
         text3,
         text4
      FROM
         content
        WHERE
            id > #value#
   </select>
</sqlMap>


I get the same result in about 1.7 seconds. Do you have any hints why the Hibernate version is that much slower than iBatis ?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 09, 2007 6:01 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
you have the system setup to do the profiling.....let us know ;)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 10, 2007 5:28 pm 
Newbie

Joined: Tue Sep 02, 2003 4:52 pm
Posts: 5
OK, I will try to get some info about this :-)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 10, 2007 6:37 pm 
Newbie

Joined: Tue Sep 02, 2003 4:52 pm
Posts: 5
I just forgot configuring Log4J properly thus all the trace calls in NullableType were made. Now transforming runs even faster than iBATIS.

Sorry for bothering the Hibernaties :-)

BTW: Netbeans Profiler 5.5 rocks

Mike


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 11, 2007 3:11 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
nice to hear ;)

_________________
Max
Don't forget to rate


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.