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
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

Trouble converting a Spring JDBC application for Spring with Hibernate

 
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Hi, I have a Spring application working with Spring JDBC and I'm trying to convert it to use Hibernate but I can't seem to get the Spring configuration right.

My application context file has the configuration for Hibernate connecting to a MySQL database. I want to use full annotations so my beans are not defined. Here is the config file:


Here is my data access class:



If I run the code like this I get the following error on the getCurrentSession() line:
No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here

I've done much searching on the internet and trying various examples. I found suggestions adding the following property.
<prop key="hibernate.current_session_context_class">thread</prop>

When I do that I get the following error on the createQuery line:
createQuery is not valid without active transaction

Any suggestions as to what is wrong with my configuration?

Many Thanks,
Ray
 
Sheriff
Posts: 67735
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Please do not post the same question more than once.
 
This. Exactly this. This is what my therapist has been talking about. And now with a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
    Bookmark Topic Watch Topic
  • New Topic