• 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
  • Ron McLeod
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Rob Spoor
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Carey Brown
Bartenders:

Spring Hibernate Integration

 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All, I am working on basic spring and hibernate application.I am using createCriteria() methods for retrieving data from database.But I have removed transaction methods (like beginTransaction() or commit).Is it possible to use criteriaQueries without transaction methods ? I understand that I can achieve this using spring transaction.But I want to do it in Hibernate.Can anyone clarify this for me ? Thanks in advance.
 
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
With JPA/Hibernate (mainly with Sprng Data JPA packages), the @EntiityManager is by default at the transaction scope, and if the transaction has multiple threads, then it is at the thread scope. The scope can be expanded with some EM options. Google the use of EM, EM Factory, etc.
So createCriteria (CriteriaBuilder, CriteriaQuery, Root) should work. I think you mainly need to set your persistence.xml, PersistenceContext, EM Factory (should be a singleton) and EM (should be per transaction/thread) correctly. You don't want to set the transaction boundaries manually.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic