信息化 频道

developerWorks


 
七、实体移除方法 
 
实体移除使用 remove 方法。 remove 方法需要你的提供一个激活的管制实体,作为一个调用的参数。

// 'em' is an EntityManager instance em.getTransaction().begin(); // use a hard-coded player id for convenience in this sample only Player player = em.find(Player.class, 5L); if (player != null) { System.out.println(player.toString()); em.remove(player); } em.getTransaction().commit();

八、其它的方法和选项
 
一个 EntityManager 实例提供了许多不同的方法来帮助你和不同的实体交互,帮助你持久化性存储。此API包括了许多的方法,用于关闭,清楚实体管理器,冲洗实体使得更好存储,刷新驻入内存中的持久化数据,锁定实体,级联操作等等。
0
相关文章