Hi, im doing transaction management, my code looks something like this
SessionFactory fact = getSessionFactory();
sess = fact.openSession();
tr = sess.beginTransaction();
MTSUserImpl user = (MTSUserImpl) sess.get(MTSUserImpl.class, new String("Marc"));
sess.setLocation("Boston");
sess.update(user);
MTSUserImpl user1 = new MTSUserImpl();
user1.setUserID("andy");
user1.setOperatorID("aa");
user1.setLocation("NYC");
sess.save(user1);
tr.commit();
sess.close();
Now my problem is that its only at tr.commit() when i get to know if the session is valid, in the sense that the insert and update queries will work fine or not. Is there a way whereby i can find out if the session saves and updates are valid or not before commiting the transaction?
|