Hi,
I have a design issue implementing my DAO's. I have seen in examples and on the net that a DAO method could typically looks like :
Code:
public void saveEntity(myDTO daily) throws DAOException {
try {
... do something ...
} catch (HibernateException e) {
throw new DAOException(e);
} finally {
... close session ...
}
}
using JBOSS with JTA transaction, it works great.
But when I write my JUnits tests, I have to enclose my DAO's method call within a 'session.beginTransaction()' and a 'transaction.commit()' . The problem is that the 'commit' fails since the session has been closed within DAO method.
other way, if I do not close the session in DAO, a warning appears when using it in JBOSS (session not properly closed).
Thanks for your help.