• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Integrate Hibernate into a new Spring MVC Project (generated by STS)

 
Billie Finn
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm new to the Spring world - and just installed STS (Spring Tool Suite), and successfully created, configured, and deployed a SpringMVC on my local machine thanks to this helpful blog post:

http://www.codejava.net/frameworks/spring/spring-mvc-beginner-tutorial-with-spring-tool-suite-ide

I was wondering if anyone had any documentation or resources that expands upon this and provides some insight on how to integrate Hibernate into a project like this? I'm new to Hibernate as well - would that be the best solution? Or is there something better out there? Appreciate the help!
 
Partheban Udayakumar
Ranch Hand
Posts: 496
AngularJS Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Billie Finn,

Welcome to Coderanch. For integration of hibernate in a spring project, you will have to add the dependency and write some configuration files. Searching "Spring Hibernate example" in google will give you the required examples. Here are two examples for Spring MVC and Hibernate,

XML Configuration :JournalDev
Annotation Configuration: Websystique

 
Billie Finn
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. I think I'm missing a basic concept here and I'm hoping you can help me out. On these tutorials, it's saying I should configure Hibernate and Spring in the pom.xml file. It asks to list specific versions. How do I know what versions I have? Do I even have Hibernate "installed"? If not, how do I do that? Thanks for clearing up my confusion.
 
Partheban Udayakumar
Ranch Hand
Posts: 496
AngularJS Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Billie Finn wrote:On these tutorials, it's saying I should configure Hibernate and Spring in the pom.xml file.


This means you will have to add maven dependencies in your pom.xml file. If your project contains a pom.xml, add spring and hibernate dependencies. Maven dependencies are lines of code which help you to integrate the required jar files. Here is the maven dependency for Spring Core 4.2.2. In this link you will see



This is the spring core maven dependency. You will have <dependencies> </dependencies> tag in you pom.xml file. Just add these lines within these tags, after any set of <dependency></dependency> tag.

In this page, you will see a search box. Just type Hibernate core in it and you will get this page
Click on the first link and you will see different versions available. Click on the required version and you will see code similar to above dependency.

OR still a better way just google, <whatever dependency you need, (say Hibernate core)> maven. It will give you the latest version page directly. Just copy these lines in you pom.xml and save it.

Billie Finn wrote:How do I know what versions I have?


For maven project:
Check the pom.xml. By default, it will have something like this


What ever the name is in the <version> tag (here spring.version), you will have it in the <properties> tag at the start of the pom.xml.



For a normal project:
Search the lib folder (/WEB-INF/lib) inside the project. You will have the jar with the version (unless you renamed it).

Billie Finn wrote:Do I even have Hibernate "installed"?

You don't have to install anything, just add the jar or dependencies in your project.

PS: Since you are using STS, I think you will have a pom.xml
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic