« Back to blog
July 18, 2008

You Can Use Native SQL With Hibernate

Recently, I read a piece at javaworld.com comparing object-relational mapping solutions. It says "Ibatis is powerfull because it allows usage of native SQL queries and Hibernate is a complete ORM solution but doesn't allow native SQL queries."

http://www.javaworld.com/javaworld/jw-07-2008/jw-07-orm-comparison.html?page=7

The link to the last page of the article is above. I met people who thinks that is true but when I saw this in a seven-page article I shocked. Hibernate clearly allows native SQL queries. Below, there is a link to the hibernate.org section of native SQL queries.

http://www.hibernate.org/hib_docs/reference/en/html/querysql.html

I don't know what make people think Hibernate doesn't allow native SQL. Hibernate is a very complex ORM tool and size of it may scare people and they may be don't dig it too much.

I used both Hibernate and Ibatis and both are sufficient ORM tools. I think the only advantege of Ibatis over Hibernate is its simplicity. Hibernate is a full ORM solution and it takes some time to learn the API but it does its job very good.



Comments (1)
İbrahim Demir said...
Hi Umit;

Also we must focus on the point that the writer mantioned. Using native SQL?

So here we must decide whether we want to be DB independent or not. If we 'r using an ORM tool why we need it? So the writer should have stated them very clearly but unfortunetely he did not.

And the last word is about the complexity.These are jut tools and they must serve us.But making complex tools cause us to server them for learning and configuration.

Remove comment

Leave a comment...
 
Got a posterous account already? Login