Srikanth Technologies

Songs Project using Web, DAO and Spring + Hibernate

This is another application to store details of songs using a Web application that uses Hibernate through Spring Core. This application is same as the previous one, Songs With Spring + JDBC, in terms of Database and View, and Spring components, but Spring beans use Hibernate instead of Jdbc to talk to database.

Create Web Application

Use NetBeans (or any other IDE of your choice) to create a new web application. It uses Tomcat. Again you can choose whatever server you like.

I am naming the project as SongsSpringHibernate as we us Spring to access database through Hibernate.

Add Spring Framework 3.0 library, Hibernate Library, and JSTL library to project. Also include OJDBC14.jar to libraries as it contains Jdbc driver for Oracle.

In order to use AOP with Spring (we use AOP for transaction management), you need to add the following .jar files:

I have made all these files available as a single download at So download and add these .jar files to your project libraries so that they are placed in the classpath.

Add the following files from one of the previous projects, Songs With Hibernate, as they remain the same for this project also.


This is configuration file for Spring beans.

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns=""
    <bean id="oracledatasource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" />
        <property name="url" value="jdbc:oracle:thin:@localhost:1521:xe" />
        <property name="username" value="music" />
        <property name="password" value="music" />
    <bean id="mySessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
        <property name="dataSource" ref="oracledatasource"/>
        <property name="mappingResources">
        <property name="hibernateProperties">
    <bean id="songsbean" class="spring.SongsManagement">
        <property name="sessionFactory" ref="mySessionFactory"/>


This is a bean in Spring that manages songs. It extends HibernateDaoSupport and uses Hibernate Template(obtained by getHibernateTemplate()) to access database through Hibernate.
package spring;

import entities.Song;
import java.util.List;

public class SongsManagement extends HibernateDaoSupport {
    public void addSong(String title, String singer ){
          Song s = new Song();
    public List getSongs() {
        return  (List) this.getHibernateTemplate().find("from Song");

That's All

As all other files remain the same, just deploy the project and run index.jsp.