This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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.
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).