This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes Other Application Frameworks and the fly likes Using HibernateTemplate inside EJB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "Using HibernateTemplate inside EJB" Watch "Using HibernateTemplate inside EJB" New topic

Using HibernateTemplate inside EJB

PavanPL KalyanK
Ranch Hand

Joined: Feb 28, 2009
Posts: 212

Hello please help me in this :

I am using Spring , EJB and Hibernate as ORM in my Application .(No JPA , there is an Hibernate dependency)

Inside my EJB

Can i use HibernateTemplate hibernateTemplate inside my EJB directly (I have configured <bean id="hibernateTemplate"> inside the applicationcontext.xml file ??

Please reply
Mark Spritzler

Joined: Feb 05, 2001
Posts: 17276

Yes you can. But if you want your EJB to have access to your ApplicationContext you will have to do some work.

Personally, I don't use the HibernateTemplate anywhere, I just inject my SessionFactory into my DAO/Repositories. As opposed to the JdbcTemplate, the HibernateTemplate just doesn't give me anything extra that I need. I can already add one simple configuration in my xml to convert all the HibernateExceptions to Spring database exceptions, if I want that. It used to be that HibernateExceptions were checked exceptions, but they aren't anymore. My 2 cents.


Perfect World Programming, LLC - iOS Apps
How to Ask Questions the Smart Way FAQ
I agree. Here's the link:
subject: Using HibernateTemplate inside EJB
It's not a secret anymore!