Hi All,
Background
----------------------
We have a back end job that is calling a Stateless
EJB (service) to process a list of entries (in an excel file). Each entry in the file represent a set of tables in the DB. Hence a record would comprise of data that would be stored in, say, 6 tables. This is basically an entry for subscribing an user to a product and also store the payment, invoice details of the subscription.
The file contains around 200 records to be subscribed, each for different users.
Problem context
---------------------
Each entry in the file are processed and stored in the DB in a single method (let me call it "processEntry") in the EJB. This EJB is defined as Container managed and also a transaction attribute is set to RequiresNew for the method "processEntry". This method is called in a loop to process each entry in the file. Our understanding with CMT is that once the method under a transaction is completed, the changes are committed to the database but what happens is that, after all the records are processed only then it commits all these records. The problem we have here is that, there are certain entries that would require to check if its parent entries are successfully inserted into the DB and also retrieve its ID. Since all the entries are committed only at the completion of the service, our check fails. Hence we would like to know:
1) what is wrong in our understanding that each time the method is called the transaction is completed and should commit the records. This doesn't seem to happen in this case
2) What is the best practise for batch processing and especially in the above case where you need to get information of the recently inserted data while processing all the entries
Also, we are using Spring-Hibernate with JTA for our DB related operations.
Technologies used
------------------------
J2EE
Hibernate 3.0.5
Spring 2.x
JBoss 4.0.2
Struts /
JSP
Appreciate if you could throw some light on this.
Thanks,
Srini