Using Hibernate Core.
I am having problems getting a detached instance of a Role object to be reattached and have the new values persisted.
Code:
session = HibernateUtil.getSessionFactory().openSession();
Role r = (Role)session.get(Role.class, "Manager");
session.close();
r.setRoleName("Manager NAME EDITED");
session = HibernateUtil.getSessionFactory().openSession();
session.update(r);
session.close();
The SQL output shows a SELECT statement instead of an UPDATE statement. This means the the role name I have edited does not persist.
Have I misunderstood the concept of detaching and reattaching objects?
From what I know, it is possible for the original session to close and have the detached object to reattach in the new session.