R
rmn190
with the following code:
public void save(User u) {
if(u!=null)
getHibernateTemplate().save(u);
}
u has not been inserted into database,but with callback,it did,as
following:
public void saveWithCallback(final User u) {
HibernateCallback action = new HibernateCallback() {
public Object doInHibernate(Session session)
throws HibernateException, SQLException {
Transaction trans = null;
try {
trans = session.beginTransaction();
session.save(u);
trans.commit();
}catch(Exception e) {
e.printStackTrace();
trans.rollback();
}
return null;
}
};
getHibernateTemplate().execute(action);
}
why?
Could you help me with that?
Thanks a lot in advance!
public void save(User u) {
if(u!=null)
getHibernateTemplate().save(u);
}
u has not been inserted into database,but with callback,it did,as
following:
public void saveWithCallback(final User u) {
HibernateCallback action = new HibernateCallback() {
public Object doInHibernate(Session session)
throws HibernateException, SQLException {
Transaction trans = null;
try {
trans = session.beginTransaction();
session.save(u);
trans.commit();
}catch(Exception e) {
e.printStackTrace();
trans.rollback();
}
return null;
}
};
getHibernateTemplate().execute(action);
}
why?
Could you help me with that?
Thanks a lot in advance!