How to delete data from org.hibernate.collection.PersistentBag? | Hibernate (Jpa)

前端 未结 1 897
说谎
说谎 2021-01-22 14:17

The List Mylist is org.hibernate.collection.PersistentBag...

and i want to delete this Mylist...
H

相关标签:
1条回答
  • 2021-01-22 15:03

    Try deleting elements one by one:

    List<String> Mylist = a.getMyList();
    em.getTransaction().begin();
    for (String element:Mylist){
        em.remove(element);
    }
    em.getTransaction().commit();
    

    _______________________
    The Solution (Work to me, thank to "Genzotto"):

    List<String> Mylist = a.getMyList();
    listStirng.clear();
    em.getTransaction().begin();
         for (String str : Mylist) {
             em.merge(str);
         }
    em.getTransaction().commit();
    
    0 讨论(0)
提交回复
热议问题