Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using HibernateTemplate inside EJB

 
PavanPL KalyanK
Ranch Hand
Posts: 212
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic