1
Java EJB的EntityManager不会更新消费者的数据。EntityManager不会在flush()上更新()
消费者登录商店,购买一些东西,并希望看看他的购物历史。一切都显示,但他最后一次购买。如果他注销并进入,它会显示。
我已经使用JPA将购买/购买(映射到消费者)持久化到数据库。这似乎是从这个会话购买不能被检测到。
代码:
public Buys buyItem(Consumer c, int amount) {
Buys b = new Buys();
b.setConsumerId(c);
b.setContent("DVD");
b.setPrice(amount);
em.persist(b);
em.flush();
return b;
}
public Collection getAllBuysFromUser(Consumer consumer) {
Collection<Buys> collection = consumer.getBuysCollection();
return collection;
}
帮助!同花顺并不做的伎俩......