• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Scott Selikoff
Bartenders:
  • Piet Souris
  • Jj Roberts
  • fred rosenberger

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.
 
Honk if you love justice! And honk twice for tiny ads!
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic