是否可以在标记为 Spring 的@Transactional的方法中执行提交?
@PersistenceContext
private EntityManager em;
@Transactional(propagation = Propagation.REQUIRED)
public void saveMembersWithMultipleCommits(List<Member> members)
throws HibernateException
{
Iterator<Member> it = members.iterator();
while (it.hasNext())
{
while (it.hasNext())
{
Member wsBean = it.next();
em.persist(wsBean); // overall commit will be made after method exit
log.info("Webservices record " + wsBean + " saved. " + i++);
}
}
}
我想在说每 500 个项目后提交给 DB。在上述背景下这可能吗?