• 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

Hibernate Template not inserting data into the DB

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
I'm unit testing a Hibernate app. The POJOs and mappings are in a JAR while placed in my app classpath. My Junit calls a Service which starts a new transaction to talk to the DAO in order to and perform any CRUD operations. The DAO is implemented using Spring Hibernate template. I'm taking care to inject a template into the DAO...there are no wiring exceptions at all.


My service can read data from the DAO. However, the problem is with insert.

Consider the code snippet taken from the DAO.


On the console I can see SELECT queries (called as a result of template.find() calls). But, I can't see any INSERT SQL statements when I call DAO.save method.
Any help shall be highly appreciated.

Thanks
Lisa
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you commit your transaction?
 
Lisa Ray
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Do you commit your transaction


Why is there a need to commit the transaction explicitly?
I'm annotating the caller of the DAO with @Transaction; by default it used the REQUIRED transaction attribute.

 
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try annotating the dao's save method with @Transactional (spring annotation), and if that in itself does not work, force it to create a new transaction by annotating it with @Transactional (propagation = Propagation.REQUIRES_NEW).
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic