Re: Putting POJO returned from mybatis into HashTable degrades the performance as it tried to load the pojo in its hasCode method

34 views
Skip to first unread message

Jeff Butler

unread,
May 11, 2013, 11:29:17 PM5/11/13
to mybati...@googlegroups.com
Try turning off lazy loading.  It may seem counter intuitive, but lazy loading very rarely provides any benefit.  I'll bet your performance increases dramatically without it.

Jeff Butler


On Sat, May 11, 2013 at 7:22 AM, Parag Dhikale <paragd...@gmail.com> wrote:
Hi All,

I am using latest mybatis release i.e. mybatis3.2.2.

I have converted our old application which was on EJB CMP to mybatis, in which the newly converted mybatis code performance was much worse than the old code with EJB CMP.

While analyzing performance issue through YJP profiler, I realized that HashTable.put(<mybatis returned Pojo>, <value>) methods were taking most of the time and seemed to be the only bottoleneck.

In the HashTable.put() method, we are putting Pojo returned from mybatis as a key. In which call, in turn it calls hashCode of that pojo, and from YJP I could see that in 'hashCode' method, it is calling 'org.apache.ibatis.executor.loader.CglibProxyFactory$EnhancedResultObjectProxyImpl.intercept(Object, Method, Object[], MethodProxy)', which is actually seemed like calling jdbc drivers and loading this pojo properties and those are the once taking all of the time.

Can any please help and guide me as in why mybatis is trying to load the Pojo while putting into HashTable in its hashCode method? Also, how can we improve its performance if at all we can.

Also, I tried to override 'hashCode' & 'equals' methods into my Pojo and used/compared only primary key properties, but it seems to have no effect, it is still calling 'executor.loader' of ibatis and doing same thing.


Thanks & Regards,
Parag

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mybatis-user...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

q8p

unread,
May 13, 2013, 3:30:10 AM5/13/13
to mybati...@googlegroups.com
The 'lazyLoadTriggerMethods' setting configures the methods that trigger lazy loading ( See http://mybatis.github.io/mybatis-3/configuration.html).

You should only do this when you are sure that the hashCode and equals implementation does not use lazy-loaded properties or uses the accessor methods for reading lazy-loaded properties.

Jurriaan

Op zaterdag 11 mei 2013 13:22:00 UTC+2 schreef Parag Dhikale het volgende:

Parag Dhikale

unread,
May 13, 2013, 11:28:22 AM5/13/13
to mybati...@googlegroups.com
Thanks a lot Jurriaan, That completely solved the problem. Really appreciate your quick reply.

Thanks,
Parag
Reply all
Reply to author
Forward
0 new messages