This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
I am trying to insert the record to DB using org.springframework.orm.hibernate3.HibernateTempla te. Everything is going fine no error on the console but when I try to see the record in the DB no record exists.(I am not using datasource.)
But, when I try to insert the record using pure Hibernate API it is working fine. Below is the code.
Interstingly, when I try to retrieve the record from the Database, it is going fine. I can iterate through all the records.
List res = rmTemplate.find("From emp e"); System.out.println("Number of records fetched " + res.size());
It is printing 22 records on the console.
I did one more test, like before inserting to DB I fetched the records it is 22. After insert it is printing 23 but when look into db its only 22. Record is somehow not committing to DB but it in the Session.
I know somewhere I am missing something. Could anybody please help me to figure out this.
Originally posted by Sabarish Sasidharan: If you are running this within a transaction and a runtime exception occurs, then the transaction will be rolled back. Are you sure you are not swallowing the exception somewhere?
I'd bet Sabarish is on the right track. Springs exceptions must be caught or they are swallowed. Surround all your db related work in a try/catch block and see what you get.