GeeCON Prague 2014*
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


JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "Using HibernateTemplate inside EJB" Watch "Using HibernateTemplate inside EJB" New topic
Author

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
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

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.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Using HibernateTemplate inside EJB