• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Spring 3 and Hibernate 4 Configuration Question

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I am working on migrating an older project to use Spring 3 and Hibernate 4. We did use the HibernateTemplate to access the database.
Since HibernateTemplate is deprecated, I using the Session Factory directly and Hibernate Transaction Manager.
I have gone through numerous examples and everything looks good to me. But I keep getting and error when I call my method that get's the current session.

Here is the error, I don't have an stack trace that relates to this error but I can provide what it does dump.

org.hibernate.HibernateException: No Session found for current thread






My applicationConfiguration.xml



my Controller:




my DAO:



I have commented out the @Transactional because when I leave it in, c3p0 fails and my service won't even start. I know it is some configuration that I am missing or have understood incorrectly.

Please let me know if you need more information. Any help is greatly appreciated.

Thank you,

Dave
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First you say you posted a Controller, but it doesn't look like a Controller, it looks like a Service.

Also, Hibernate requires that you have a transaction. so you have to have @Transactional somewhere

Also, you inject the transactionManager into your DAO? Why, your DAO doesn't need it.

Your xml configuration looks correct for transactionManager, sessionFactory and dataSource.

Why is C3PO pool throwing an exception? I would concern myself about that.

Please post your code for public SearchResultsType nameSearch(PersonNameType personNameRequest, Date searchFromDate){

How are you using the sessionFactory injected into your Repository? It should start with sessionFactory.getCurrentSession().

Thanks

Mark
 
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I use JPA myself but if you don't have a transaction you would have to open it manually



nice article on it here
http://blog.springsource.org/2012/04/06/migrating-to-spring-3-1-and-hibernate-4-1/

If you need CGLIB is it on the classpath?
 
Bill Gorder
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Edit - nvm I missed the <tx:annotation-driven transaction-manager="transactionManager" /> in your config I thought it was missing.
 
reply
    Bookmark Topic Watch Topic
  • New Topic