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????
}
}
非常感谢!!
答案 0 :(得分:0)
尝试逐个删除元素:
List<String> Mylist = a.getMyList();
em.getTransaction().begin();
for (String element:Mylist){
em.remove(element);
}
em.getTransaction().commit();
<强> _______________________
解决方案(对我有用,感谢&#34; Genzotto&#34;):
List<String> Mylist = a.getMyList();
listStirng.clear();
em.getTransaction().begin();
for (String str : Mylist) {
em.merge(str);
}
em.getTransaction().commit();