该List<String> Mylist是org.hibernate.collection.PersistentBag…
List<String> Mylist
org.hibernate.collection.PersistentBag
和 我要删除这个MYLIST ...... 我该怎么办呢?
QriteriaBuilder criteriaBuilder = em.getCriteriaBuilder(); CriteriaQuery<A_entity> criteriaQuery = criteriaBuilder.createQuery(A_entity.class); criteriaQuery.from(A_entity.class); Query query = em.createQuery(criteriaQuery); List<A_entity> queryList = query.getResultList(); for (A_entity a:queryList) { if(....) { List<String> Mylist = a.func(); ???How delete Mylist???? } }
非常感谢你!!
尝试一一删除元素:
List<String> Mylist = a.getMyList(); em.getTransaction().begin(); for (String element:Mylist){ em.remove(element); } em.getTransaction().commit();
_____ 解决方案(对我有用,感谢“ Genzotto”):
List<String> Mylist = a.getMyList(); listStirng.clear(); em.getTransaction().begin(); for (String str : Mylist) { em.merge(str); } em.getTransaction().commit();