views:

5125

answers:

3

I need a quick jump start for using Spring and Hibernate together and I was looking for some sample code to modify and extend. Bonus points for Struts2 and Spring Security integration.

+4  A: 

The official docs is your best bet for both Spring and Hibernate. However, you can look into When Spring Meets Hibernate and Spring and Hibernate with MyEclipse tutorial to get you started.

Your best bet, if you are using Netbeans or have no problems in using that, just start a brand new application and follow the web application wizard and specify Spring and Hibernate as application framework, and ORM respectively. It will generate a complete skeleton for you to work on. You can even add Struts2 as web framework later, in project->properties->framework.

You might want to look into Struts2 Spring Plugin for the latter. Further, Spring Security Integration.

Adeel Ansari
+2  A: 

There is a sample project that includes Spring, Hibernate and Struts2 available from the Struts2 website that appears to have most of what I want. It includes a basic JPA configuration but it does not provide DAO classes.

The generic DAO pattern is documented on the Hibernate site here. This gives a good DAO foundation but the code is using Hibernate directly with no JPA or Spring.

The following post (warning: language) gives some information about using Spring with JPA and not the HibernateTemplate class.

Put together this information has me well on the way to my skeleton project.

Peter Kelley
+3  A: 

Have a look at AppFuse

It has lot of starter web-app material. You also have something with Struts2-Spring-Hibernate.

Satya
Does Appfuse allow me to use Struts2 rather than Spring MVC? I couldn't see it mentioned on the site.
Peter Kelley
Have a look at this url https://appfuse.dev.java.net/ It has some demo videos as well as downloads for struts2 as well.. Hope it helps.
Satya