我面临一个奇怪的问题:刷新具有嵌入式ID的实体时,EntityNotFoundException仍然被抛出。
代码:
@Entity
public class A {
@EmbeddedId
private APk pk;
public A(int id, Date date) {
pk = new APk(id, date);
}
...
}
@Embeddable
public class APk {
private int id;
@Temporal(TemporalType.TIMESTAMP)
private Date date;
...
}
然后,在EJB方法中:
A entity = new A(1, new Date());
em.persist(entity);
em.flush();
em.refresh(entity); -> here's where the exception is thrown
Stacktrace:
javax.persistence.EntityNotFoundException: Entity no longer exists in the database: [id=1, date=25-07-2013 15:02].
我正在将Glassfish v3.1.2与Eclipse Link 2.4.2一起用作JPA提供程序(但它与嵌入式提供程序的做法相同)。
你能帮我吗?
感谢。