You can view the tutorials best in Google Chrome, Mozilla Firefox, Opera, higher version of Internet Explorer

Struts 2 Hibernate Integration Example [ Struts 2 + Hibernate Integration]

Hibernate » On May 13, 2012 By Sivateja

Let us see how to integrate struts 2 application with Hibernate, a real time application. Make sure you are well aware of the following topics before you read this article.

  • Static – Core
  • HQL – Hibernate
  • Taking separate bean to store the values – Struts

See HibernatePlug.java,  my aim is to make SessionFactory as singleton.  As a programmer its our responsibulity to make SessionFactory as singleton,  People used to say HibernatePlugin plugin plugin bla bla., but all it could be is to make SessionFactory as singleton, and remaining is just struts only :-)

Directory Structure

HibernatePlug.java

index.jsp

retrive.jsp

insertScreen.jsp

successOperation.jsp

edit.jsp

error.jsp

Java4sController.java

Links.java

Mybean.java

MyOperations.java

web.xml

struts.xml

Mybean.hbm

hibernate.cfg.xml

Java4s.css

Output






By [ Java/J2EE Developer & Web Designer ]
Founder of Java4s.com - Indian, lives in United States. You can contact me at sivateja [at] java4s.com
Follow me on


Comments

46 Responses to “Struts 2 Hibernate Integration Example [ Struts 2 + Hibernate Integration]”
  1. Mohammed Vaseem says:

    Thanks a lot for uploading this application Java4s. I was in very much need of this type of application…

  2. veerareddy says:

    Good application, it as useful to many programs as a base.

    Thanks to java4s team

  3. Java4s says:

    @Vaseem, @VeeraReddy

    You bet :-)
    thanks much.

  4. Vivek says:

    Great work by java4s. i just completed hibernate tutorial & done all example in netbeans ide. Just one suggestion, you should put UML diagrams of database table, so that it would easy to understand relationships by beginners. Now its time to move on spring let’s see hows it.

    Thanks

  5. Java4s says:

    @Vivek

    Good to here :-)

  6. KRISHNARAO NETHINTI says:

    good program. very useful for us.. thanq for giving ..

  7. Harish Chand says:

    Thanks a lot, All Example with explanation are perfect.
    Easily understandable.

  8. Java4s says:

    @Harish Chand,@KrishnaRao

    You welcome friends, thanks for your feedback.

  9. Greeshma says:

    Thanks for a very nice tutorial. It would be helpful, if you can provide a zip file of the jar files to download that you used in this example. I face lot of issues in searching for the correct version of jar files that you showed in your screenshot for lib folder.

    Thanks again for the wonderful tutorial.

  10. Java4s says:

    @Greeshma

    I have provided the download link, with source code including all .jar file(s). Click on ‘DOWNLOAD NOW’ button to download every thing to your local :-) enjoy the app.

  11. varun says:

    Java4s is easy to understand ,good job

  12. Saptak says:

    Sir Plese give the code for export pdf,excel,doc,csv & xml in struts2.

  13. i search for this example around 50 websites but no explanation. this is only one website to understand the flow. really thanks to java4s people.

  14. ameer says:

    @Java4s, what is this jar “struts2-fullhibernatecore-plugin-2.2.2-GA.jar” in google code?

  15. abdullah says:

    Great tutorials series. Good Jobs. Moving on Spring..

  16. anurag says:

    nice application.
    thanks

  17. Srinivas says:

    Super app…really fantastic…..thank u very much @java4s

  18. apatic says:

    everything is good but, if the program had comments, then, it would have been a lot easier to newbies.

  19. naresh says:

    nice work,very useful

  20. Suganthan says:

    Thank You very nice example

  21. Baji says:

    hi shivateja plz send an application on sprins(DTO,DAO)+struts+hibernate only these things can required

  22. Paresh Patel says:

    Thanks a lot,good discription

  23. Nice work ,

    Very Thankful to you….

  24. Kamal8878 says:

    Hi,

    Nice work…Published any books from this site?

  25. awesome tutorials ………..

  26. Saroj says:

    Very nice work thanks alot for helping all the learners like me…….

  27. Sadheesh R says:

    hi shivateja,
    I worked out your program,Thanks for a very nice tutorial. if you give comments,then it will be more easier to understand the code flow.

    thanks,

  28. Anand Jain says:

    thank you so much..java4s…it was really helpful learning from your site…and the example were so well explained..finally I could say that now I know Struts and hibernate..and thats coz of java4s..:)

  29. Srinivas says:

    very nice tutorial for freshers and refresh basics for students

    thanks to Sivateja.

  30. jerrin says:

    The website is nice. can get to know all the hibernate concepts on the same place. Please provide an index page so that we can navigate to the pages easily. Thanks

  31. Abhijeet Tomar says:

    Superb series of Struts and Hibernate…Thanks Sivateja.
    Well done..

  32. Saidulu says:

    i am new to struts2 and hibernate. when i study this application i got more than i excepted nice post

    ThanX a lot To TEAM.

  33. irfan says:

    plz, if possible give an example of hibernate and struts2 integration with the help of annotations. thanks

  34. Sridharan.T says:

    The above example is working fine…thanks for you great work..
    also please provide a simple example with spring + struts2 + hibernate

  35. KrishnaKanth says:

    Thank god somehow i found this site otherwise i would have struggled a lot to understand this concept,very useful, you made me learn on my own thanks a lot..

  36. The main plus point in your website is easy to understand by any one,rich look and with the good stuff so what is the need to go for the other websites,I did not see any website like this.Really Great.We will thank full to you Sivateja.

  37. Hello Java4s,

    I was the person who first commented this article.

    You are doing a great job by making us learn java in an easy manner.

    I just wanted to know that the coding methods/standards presented in this article is depicting to what coding standards industry follows.

    I know that for a beginner this is the recommended site to have

    Thanks for looking my post.

    Cheers,
    Mohammed Vaseem.

  38. Hello ,

    It is really nice website that any one can learn and explore very easily.
    It helped me a lot..

    Thanks a lot .. :)

  39. Hi Shiva ,

    i have some problem for understood your please clear my confusion .

    you have used in your edit jsp {value=”%{#application.x}”} like that in there what represent application keyword . Please give me reply as soon possible as.

  40. Ananth105 says:

    Great Work I Just Love To Visit Java4s Everytime..Good Explanation and I succesfully completed my struts classes now time to move Spring..java4s is nothing but enjoy the programming Good Luck :-)

  41. Salamon says:

    Really nice…………it will be very much helpful to continue…

    Thanks a lot Bro !!

  42. **** says:

    Besides the navigation everything is good. Please introduce index in the left for simple navigation

  43. Pravin says:

    Thank you… It’s worth to read you’re document.

  44. Andy says:

    If the purporce of HibernatePlug is singleton then why did you make getSessionFactory()as public?

Name*
Mail*
Website



By posting your answer, you agree to our comments policy.
Most Recent Tutorials
Hibernate Recent Posts
Spring Recent Posts
Struts Recent Posts
Recomandded Links
Current & UpComing Tutorials
Sitemap :
spring Hibernate struts Json Ajax Log4j Log4j coreJava Servlets Web Services


Upcoming
  Web Services [ SOAP ], JSP
Facebook_Java4s  Twitter_Java4s  GooglePlus_Java4s  Youtube_Java4s 
© 2010 - 2014 Java4s - Get It Yourself.
The content is copyrighted to Sivateja Kandula and may not be reproduced on other websites.