I have an application which uses Spring, Hibernate and JTA.
We received a request with larger than expected data (10000 elements), general requests are 10-100 elements.
While processing this request we try to insert a record in DB for each of these elements and that's done in a for loop
pseudo code:
processRecords( list){
for (Element element: list){
dao.findBy -- This takes around 100 ms
-- some other checks and logic
dao.add(element); -- This takes around 150 ms
dao.flush();
}
}
This block takes a lot of time to process the records and then I get *
"javax.persistence.TransactionRequiredException: no transaction is in progress"
*
I tried moving the flush out of the for loop, did not help, I tried researching on batch inserts for hibernate , but this is a huge application with lots of customization and I do not see that as an option as it will impact whole application, Also I tried finding where is the Transaction duration configured and only place I could find was in JTA on weblogic and it was set to 480 Sec.
Any indicators on how to solve this scenario would be much appreciated.
Edit: increasing the JTA Timeout in weblogic has solved the problem temporarily, but I set it to a very large value 5000 sec, is there anyway to improve the performance, since I am just inserting 8K records (I know batch processing is one option, but there are some constraint in custom "framework" around that)