j2ee Archive

Introduction to HibernateUtil and the SessionFactory Interface

HibernateUtil is a convenience class for obtaining the Hibernate SessionFactory instance, which are used for building hibernate sessions. Hibernate sessions themselves are not thread safe i.e. there exists only one per thread of execution (used once and then discarded). A typical HibernateUtil class looks like: [crayon-5b7b1d5765a84948120313/] Some important points worth noting regarding the SessionFactory:...

What is dependency injection?

We, as a java programmers rely on low coupling of the java components/classes. This aims at increasing the re-usability of the components and also help in independent testing of the component. To supplement to this feature, Spring came into picture and through its dependency injection capability, it helped the dependencies of a class...

Hibernate configuration and mapping file

There are several ways to configure Hibernate. Having the HibernateUtil convenience class ready as we had learnt earlier in the previous post, we can go ahead using it to configure the Hibernate application with the Oracle Database. Note the following line in the HibernateUtil class, [crayon-5b7b1d576655f617744989/] This would search for the Hibernate...

Spring integration with hibernate

Almost similar to what we have done in our previous article on a login application in Spring using JDBC template. To demonstrate the Spring integration with Hibernate, we will instead be using HibernateTemplate. Quickly moving ahead with the application, lets configure the web.xml first web.xml Location: /WebContent/WEB-INF/ [crayon-5b7b1d57676e6615359789/] Next, let’s configure the dispatcher-servlet.xml dispatcher-servlet.xml...

Get more stuff like this
in your inbox

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.