Spring MVC and Hibernate Web Application One-to-One Mapping Database Example [XML Configuration]

In this article, you will learn how to Create Spring MVC and Hibernate Web application with One-to-One mapping. And also you will learn how to integrate Spring MVC and Hibernate with XML Configuration. We will be creating a simple Book Management Application. So let’s get started.

Application Features:
    Book Management Application provides the following features,

  • Create book
    • single book – User can create/add single book to the application
    • multiple book – User can create/add multiple books to the application
  • Delete book – User can delete the book from application
  • Search book by
    • book type – User can search book by book type (Category)
    • book id – User can search book by book id
    • book name – User can search book by book name
  • Book quantity
    • Increase – User can increase the book quantity
    • Decrease – User can decrease the book quantity

Tools and Technologies Used:
    Following are the tools and technologies used to create application,

  • Spring 3.2.3
  • Hibernate 4.1.8
  • Java 7
  • Mysql connector 5.0.5
  • Eclipse Oxygen
  • Mysql workbench
  • Maven 3.1

Step 1: Create a database with name bookmanagement (you can give any name you want)

Step 2: Create book_type and book_details tables on the database

book_type table

book_details table

Step 3: Create a maven project with name bookmanagement


Step 4: Create 4 packages as shown in the image under src/main/java and add the following dependencies to the pom.xml file

Step 5: Create jdbc.properties for database configuration in the src/main/java folder in the created project

Step 6: Create all the necessary java classes under the respective packages as shown in the Step 3 image

Step 7: Create web.xml and spring-servlet.xml configuration file under webapp/WEB-INF folder

Step 8: Create a sub-folder with a name jsp under the webapp/WEB-INF folder. Create a view file book.jsp and bookdetails.jsp under this sub-folder.

Step 9: Create resources folder under webapp and create 2 sub folders css and javascript under resources folder

Step 10: Download jquery core library, jquery UI library and add it to the respective folder as shown in the Step 3 image
















Once you are done with creating source and configuration files, run the application. 

That’s it for this article, i hope this article helped you in some way or the other way. Please share this post with your colleagues and friends.

Thanks and Regards,
Bhushan SC

About the author

Bushan Sirgur

Well, I am Bushan Sirgur from Banglore, India. Currently, I am working as a Software Developer in a Service Base Company. I am interested in JAVA/J2EE, Angular 2, JavaScript, jQuery, MongoDB.

View all posts

1 Comment

  • I’m amazed, I must say. Rarely do I come across a blog that’s both educative and amusing,
    and let me tell you, you have hit the nail on the
    head. The problem is something which too few folks are speaking intelligently
    about. I’m very happy I found this in my hunt for
    something regarding this.

Leave a Reply

Your email address will not be published. Required fields are marked *