我有两个不同版本的J2SE实现,可处理200个项目的列表
实施1:
//1 Setup EntityManager and begin a transaction
//2 Runs thru the list of 200 items and do entityManager.persist() for each
//3 Commit the transaction
实施2:
//1 Setup EntityManager and begin a transaction
//2 Create a workStealingExecutorService
//3 Adds callable tasks which partitions the list of 200 items into 20 lists
//4 execute the same method being run in #2 of the Implementation 1
//5 invoke the executorService.invokeAll
// Commit the transaction
我的实现1总是成功运行,并将200条记录插入DB。 实施#2成功执行了persist(),但是在提交事务阶段它总是抛出错误。
请帮助我更清楚地了解这个问题。