Search Results

Search found 1 results on 1 pages for 'user2535201'.

Page 1/1 | 1 

  • Java Hibernate session delete of object

    - by user2535201
    I'm really struggling with hibernate sessions, I never have the result I expect when making a query on a modified session object. I think all my problems are related. The last one is the following : final Session iSession = AbstractDAO.getSessionFactory().openSession(); try { iSession.beginTransaction(); MyObject iObject = DAOMyObject.getInstance().get(iSession,ObjectId); iObject.setQuantity(0); //previously the quantity was different from zero DAOMyObject.getInstance().update(iSession,iObject); DAOMyObject.getInstance().deleteObjectWithZeroQuantities(iSession); iSession.getTransaction().commit(); } catch (final Exception aException) { iSession.getTransaction().rollback(); logger.error(aException.getMessage(), aException); throw aException; } finally { iSession.close(); } What I'm not getting is why the object is not deleted, since I'm modified it in the session, the query making the delete should find it. I had the same problem with creating an object with an incremental id in a session, then creating another one in the same session before the commit, with a select max(id)+1. But the session gets me the same number of id every time.

    Read the article

1