Integration of Hibernate with Spring
Spring is a powerful middle tier framework which has got good support for Hibernate. In Hibernate we perform the operations like save,update,merge etc. using session. If we are using spring we can perform all these and many more tasks using Hibernate Template. In order to use Hibernate template(There are other ways too.I personally feel this is the simplest way) we need to define an interface containing all the methods of the DAO class. The DAO class must implement this interface and extends HibernateDaoSupport. By doing this we can perform all the operations. Advantage of using Hibernate Template is that it performs the session and transaction management by itself and we don’t have to implicitly open and close the session or begin and commit the transaction.
HQL
Hibernate provides a simplified language for querying into the database. Its called HQL-Hibernate Query language.
We can use SQL Queries directly in hibernate,So naturally a question may come.Whats the need of using HQL if you can perform the same with SQL ?
1.HQL is very simple. Its very easy to learn and manipulate.
2. HQL engine generates the most appropriate SQL for a particular task from a set of SQL statements.
3.Usage of HQL will help in application portability. We can change the Database from say Oracle to MySQL without changing any HQL queries. Only change needed is in the Configuration file where we need to specify the appropriate driver and dialect.
These are some of the advantages of using HQL. I will keep you updated with more advantages soon.
Pointers
Learn hibernate from Gavin King,Christian Bauer and team. They are the creators of hibernate. Recently i read about Gavin, he has only 5 years of experience working with Java and went on to create a framework of this magnitude.Infact knowledge of Java is not the essential thing you need to learn Hibernate.You have Nhibernate if you are a fan of .NET technologies. Gavin and Christian are presently working for the JBoss project and he is also an active member of the EJB spec. group.
Visit Hibernate home page Hibernate Core
Read the documentation .
There are also many tutorials available in the web. wait..!!! I am gonna post a tutorial in Hibernate where i will help you in each and every step of learning hibernate.
PS: I am having some problems with my Eclipse IDE. ie y the delay in posting the tutorial
-
Archives
- February 2012 (1)
- July 2009 (1)
- June 2009 (1)
- May 2009 (7)
-
Categories
-
RSS
Entries RSS
Comments RSS