antoinepraetor wrote:
Quick question
Here is an example of code that is not working as i am expecting. All code in a single Thread.
session = sessionFactory.openSession();
session.setCacheMode(CacheMode.IGNORE);
menu = (Menu)session.createQuery("from Menu where menuId = "+menuId).uniqueResult();
menu contains object content,
content = menu.getContent();
tx = session.beginTransaction();
session.delete(content);
tx.commit();
in same thread few lines of code later
menu = (Menu)session.createQuery("from Menu where menuId = "+menuId).uniqueResult();
content = menu.getContent();
session.close();
content is not null, how i can make the code make the content be null on the 2th attemp ?
Antoine
The session.delete(content) statement deletes the "content" from the database. It doesn't change the value of content. As long as you maintain a reference to it, it's still a valid java object.
See section 10.8 of the reference doc.[/code]