Newsletter |
Hibernate In Servlet Example, Hibernate In Servlet Tutorial
Hibernate » on Jul 20, 2011 { 5 Comments } By Sivateja
With servlet, if we want to do some operations on the database, then we can also use hibernate ORM rather than JDBC. We call this as servlet-Hibernate integration.
While integration servelt with hibernate, it is there to follow these setps
- In init() method of servlet, we need to create SessionFactory of hibernate, because SessionFactory is an heavy weight component, its the programmer responsibulity to make it as singleton, for this we need to create the object of SessionFactory in init() method of servelet
- Open a Session in service() method and perform the operations on the database close the Session in service()
- Close the SessionFactory of hibernate in destroy() method
- While integration servlet with hibernate, hibernate mapping files (.hbm.xml) and hibernate configure files(cfg.xml) need to be stored in classes folder only
- In the lib folder, we need to store all the jars related to hibernate and database
Let us see an example on this servelt with hibernate in the next session
You Might Also Like
::. About the Author .:: | ||
Comments
5 Responses to “Hibernate In Servlet Example, Hibernate In Servlet Tutorial”
Thanks allotted…
Thanks alot
But in your site there is some spelling mistakes is there correct them for site development.
I thought my comment is help full for you if not ignore it.
Thank you!
@Mahi, I think they ignored it. 😀
@Mahi, @Maha – I haven't ignored this :-), When ever I got sometime I am concentrating on the new tutorials. I am parallely working on spell corrections too.
I want to do CRUD operation using html, servlet,Hibernate.Give me a example how to integrate servlet and hibernate.