开发常见问题整理
JPA parallelStream 调用 manyToMany 清除关联关系无效 @Transactional(readOnly = true) public void clearAuthorBooks() { List<Long> ids = new ArrayList<>(2); ids.add(1L); ids.add(2L); ids.parallelStream().forEach(this::newTransaction); } @Transactional(propagation = Propagation.REQUIRES_NEW) public void newTransaction(Long id) { authorRepository.findById(id).ifPresent(author -> author.getBooks().clear()); } 这里使用基于注解的 Spring 事物,Spring 中大量使用基于代理的...