【发布时间】:2015-08-22 13:24:26
【问题描述】:
我正在尝试在以下方法中运行 entityManager.merge(myEntity),但似乎忽略了 @Transactional 注释。 Hibernate 配置似乎很好,因为我可以成功地从数据库中获取数据,但无法写入数据库。我正在使用 Spring 3.2.3 版。为什么写入数据库操作不起作用?
我的方法不起作用
package com.reflections.importer.bls;
...
@Service
class BlsGovImporter {
...
@Transactional
private void importSeries(String externalId) {
// This works. The dao is using EntityManager too
Series series = seriesDao.findByExternalId(externalId);
series.getValues().addAll(fetchNewValues());
// This does not work and no exception is thrown
entityManager.merge(series);
}
【问题讨论】:
-
您的 BlsGovImporter 类位于哪个包中?在“com.reflections”中?
-
它位于 com.reflections.importer.bls 包中
标签: java spring hibernate spring-mvc spring-transactions