我使用Hibernate 4.1.10.Final作为JPA提供者(与Spring容器),我努力坚持后,它更新一个JPA实体,但每次我得到消息的org.hibernate.StaleObjectStateException:行被更新或者删除另一个事务(或未保存的值的映射是不正确的):... 我的代码很简单:保留后无法更新JPA实体?
@Transactional
public void test() {
TestEntity e = new TestEntity();
e.setName("test");
......
em.persist(e);
......
e.setComment("memo...");
}
有什么东西错了吗? 非常感谢您的帮助。
顺便说一句,在TestEntity类有一个版本字段:@Version \t @Column(name = “更新”,插入= FALSE) \t更新私人时间戳; – smile