O'Reilly logo

Spring Persistence with Hibernate by Ahmad Seddighi

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Applying IoC to Hibernate resources

Hibernate applications may use either container-managed or application-managed connections behind the scenes. We can use IoC in a Hibernate application and configure a data source as a bean. IoC lets us manage the data source transparently and declaratively. Therefore, we can look up the container to obtain the SessionFactory object initialized with a configured data-source object.

We can assume that SessionFactory is a singleton bean in the Spring IoC container. However, configuring a SessionFactory as a bean is not effortless as it has many properties and a complex structure. For this and similar cases, Spring provides a specific type of bean called a factory bean.

A factory bean is a bean inside the IoC container ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required