File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Spring and the fly likes Integration Of Spring with Hibernate using Oracle Database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Integration Of Spring with Hibernate using Oracle Database" Watch "Integration Of Spring with Hibernate using Oracle Database" New topic

Integration Of Spring with Hibernate using Oracle Database

Vivek Kr Agrawal
Ranch Hand

Joined: Sep 08, 2012
Posts: 51

Hi Everyone,
Problem Scenario:Putting dataSource from Persistence.xml and ApplicationContext.xml at one place.
I am having a tough time integrating Hibernate with Spring framework. I am following strict JPA guidelines in the framework. So I am having one persistence.xml and some orm.xml which basically contains the mapping. In my persistence.xml I am providing the dataSource as hibernate standards.Everything is working fine with this configuration:-

In my applicationContext.xml(Spring xml) I am doing

But the point is that I don't want to declare give my db details at two places. Putting all db details in application context makes more sense. So i tried integrating using sessionFactory bean concept provided at various sites but still have no success.
I am trying to all this new bean in my applicationContext.xml

Can you please provide me a good example how to put all my datasource at one place.

Vivek Agrawal
Bill Gorder

Joined: Mar 07, 2010
Posts: 1648

You do not need the sessionfactory bean, you are using a LocalContainerEntityManagerFactoryBean. You can just remove the db connection details from the persistence.xml, it is not needed there.

[How To Ask Questions][Read before you PM me]
I agree. Here's the link:
subject: Integration Of Spring with Hibernate using Oracle Database
Similar Threads
Getting No suitable driver error using hibernate.
Spring MVC - Url Handling Problem
Hibernate + Spring + Oracle: Help, can't get connection working
The chosen transaction strategy requires access to the JTA TransactionManager
java.lang.IllegalArgumentException: Unknown entity