Found shared references to a collection org.hibernate.HibernateException

前端 未结 12 1299
一整个雨季
一整个雨季 2020-11-27 15:48

I got this error message:

error: Found shared references to a collection: Person.relatedPersons

When I tried to execute ad

12条回答
  •  北海茫月
    2020-11-27 16:15

    Reading online the cause of this error can be also an hibernate bug, as workaround that it seems to work, it is to put a:

    session.clear()
    

    You must to put the clear after getting data and before commit and close, see example:

    //getting data
    SrReq sr = (SrReq) crit.uniqueResult();
    SrSalesDetailDTO dt=SrSalesDetailMapper.INSTANCE.map(sr);
    //CLEAR            
    session.clear();
    //close session
    session.getTransaction().commit();
    session.close();
    return dt;
    

    I use this solution for select to database, for update or insert i don't know if this solution can work or can cause problems.

    My problem is equal at 100% of this: http://www.progtown.com/topic128073-hibernate-many-to-many-on-two-tables.html

提交回复
热议问题