Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Application crashes or closed before batch insert is completed

 
Kunal Lakhani
Ranch Hand
Posts: 622
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am working on a hibernate application
In my Dao class there is a for loop
in this for loop following steps are repeated for all registered members

Step 1 : Get the new member id
Step 2 : Perform some action, save it, transaction.commit, shutdown the session.
Step 3 : Different session, transaction object. Get the object saved in Step 2, perform some actions, save a new different entity, transaction.commit
Step 4 : Go to step 1, get the new member id, and repeat steps

As soon as the members id list is over, come out of Dao

My problem is, what if, in between the process , any exception is raised, or , computer shuts down? The remaining id wont run. Its also necessary to use "transaction.commit" in step 2, as step 3 uses it. Also, these steps corresponds to a single id each time a for loop runs

The point to be noted is, either all the codes of that class should run successfully, or if, everything is roll backed (in case of exception)
Also, what if pc shuts down, or browser is closed, I dont think there is any solution to it. And the application will crash / or incomplete batch inserts will run (i am afraid of that)
 
Kunal Lakhani
Ranch Hand
Posts: 622
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No reply yet

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic