0 Replies Latest reply on Nov 19, 2014 11:21 AM by fbenbassat

    Hibernate retrieving dirty object


      I'm facing problems with hibernate that sounds to be related to object caching.

      Destilling the problem, I have an entity, lets call it A, with a list attribute mapped with @OneToMany(cascade=CascadeType.ALL, mappedBy="attribute"). The objects on the list are entities of class B and has a bidirectional relationanship with A. So B has an attribute that points to A mapped with @ManyToOne(cascade=CascadeType.MERGE). I get the object A from database and add a new object B to A's list and call session.update(A).

      The problem emerges when I get all A objects calling session.createCriteria(A.class).list();, access exactly the A object I updated and the B object I added is NOT present in the list SOMETIMES.

      I tried to call session.refresh(A) after update A, but the problem still persists.

      Does anyboy know how to deal with it.