My understanding of the persistent context is that it is equal to the session. But I'm a bit confused. What happens in the following code?
Code:
Session session = sessionFactory.openSession();
Transaction tx = session.beginTransaction();
User user = session.load(User.class, new Long(1234) );
user.setName( 'Billy');
tx.commit();
user.setName( "jimmy' );
Transaction tx2 = session.beginTransaction();
tx2.commit();
session.close();
So, if the session was never closed, then user was not detached? At least that's how I understand it. Does this mean that the name will be set to Jimmy in the DB?