Create a bean configuration file (Stock.xml) for BO and DAO classes, put it into the “resources/spring” folder.

Dependency inject the dao (stock Dao) bean into the bo (stock Bo) bean; session Factory bean into the stock Dao.

If you have a few years of experience in the Java ecosystem, and you're interested in sharing that experience with the community (and getting paid for your work of course), have a look at the "Write for Us" page. Eugen This article will show how to implement the DAO with Spring and Hibernate.

Hibernate Dao Support – This class is a convenience class for hibernate based database access. The class can also be initialized using a preconfigured Hibernate Template.

Create your own DAO by extending this class, provide a Session Factory or Hibernate Template and start performing operations using the method.

Now, you can execute the Hibernate function via get Hibernate Template(). Create a properties file ( for the database details, put it into the “resources/properties” folder.

It’s good practice disparate the database details and Spring bean configuration into different files.

Spring manages the creation and shutting down of the factory.

Hibernate Template provides methods such as find, save Or Update, persist, delete etc that performs the corresponding function in hibernate but manages sessions and exceptions. Create a session factory bean configuration file (Hibernate.xml), put it into the “resources/database” folder. Hibernate: delete from mkyong.stock where STOCK_ID=?

This Local Session Factory Bean class will set up a shared Hibernate Session Factory in a Spring application context. STOCK_NAME as STOCK3_0_ from mkyong.stock stock0_ where stock0_. Stock [stock Code=7668, stock Id=11, stock Name=HAIO] Hibernate: update mkyong.stock set STOCK_CODE=?

Hibernate Template – Spring provides a class called org.hibernate3.