Is iBatis really over twice as fast as JPA?
So, i've been reading up on JPA off and on for awhile now. Yesterday, i finally decided to get it working. After a day and a half of frustration trying to get jpa (hibernate provider) and Spring 2 working (mostly due to hibernate and JPA issues)...I finally was able to get a simple query to work.
Our live site has used ibatis since its inception. However, i know that you can make JPA look a lot like ibatis, except JPA can use annotations instead of sql map xml files. So, JPA can use annotated column names in your model, instead of using a result map in the xml. Also, JPA can used named queries in annotations, instead of named plain SQL queries in xml. At least for how we use ibatis, JPA can be made to work just like an annotation based ibatis, which is pretty cool.
Anyway..i finally got a simple query working in JPA/Hibernate/Spring. I decided to run the query 50 times, and compare it to the same query in ibatis/Spring.
I ran the test several times, below is a sample of the results:
Total JPa query time: 12.108
Total ibatis query time: 4.556
Total JPa query time: 11.707
Total ibatis query time: 4.867
Total JPa query time: 12.128
Total ibatis query time: 4.857
Needless to say, i was pretty shocked. Both tests use the same DataSource, with the same connection params (in fact, both are configured in the same spring config file). Neither version is using any caching. The query has no joins..just a straight select from one table, that returns the same approx 40 columns. All logging is also turned off (even jpa sql logging)..nothing appears in the console, except my system.out statements with the query times.
So...with an equivalent setup in each environment..it appears that ibatis is significantly faster than JPA...i'm guessing its most likely in the result mapping, but I'm not sure.
I'm sure there are things in both versions that i could do to tweak the performance, but i wanted the raw results of just performing a query, retrieving the results, and mapping them to an object.
Has anyone else seen similiar results? I cant see how my setup could have affected this test, as I am just using a basic sql query in both cases. I would like to see someone else run a similiar test, and see how their results turn out. I'm not sure I believe my results, but then again, I dont see how they could be wrong, either.
