• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt in Transaction

 
Sathish Kumar Govindan
Greenhorn
Posts: 18
Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


In the above Code, Consider con is an active Connection and the code is wrapped with proper Exception Handling.. I want to know whether the records will be commited or not...
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
 
Sathish Kumar Govindan
Greenhorn
Posts: 18
Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Paul,
<pre>

As You said it was not working.. The Records have been inserted after executing the code....
I am Using Oracle thin driver....I think whenever we don't give commit or rollback and closing the connection smoothly,
the cached transactions are getting commited even though we set AutoCommit as false...

</pre>
with thanks,
Sathish Kumar.G

 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What cached transactions?

If your insert statements are successful, and you can query the database for these two records after your program has completed then one of two things could be true:
  • the code below is not the code you are running.
  • your driver is buggy


  •  
    Salil Vverma
    Ranch Hand
    Posts: 257
    Hibernate Oracle Spring
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hey Satish,

    I tried the following three code sections. In the first one when I used conn.commit(), the changes got committed. I verified that by firing the select query in database from pl/sql developer. In case of second and third code sections changes were not persistent and were not committed.

    First -




    Second




    Third




     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic