Project

General

Profile

bug #7106

Updated by Andreas Kohlbecker over 6 years ago

 the usage of `factory.openSession()` in CdmRepository and DaoBase seem unnecessary and can potentially be dangerous since sessions should generally be managed through the HibernateTransactionManger only. factory.openSession() should only be uses in dedicated special cases, therefore the current implementation of `getSession()` in these classes seems as a error prone convenience hack: 

 ~~~java 
 protected Session getSession(){ 
         Session session ; 
         try { 
             session = factory.getCurrentSession(); 
         } catch (HibernateException e) { 
             session = factory.openSession(); 
         } 
         return session; 
     } 
 ~~~ 

 In the dao context calling `factory.openSession()` should never be necessary, since dao methods are always only used from service methods which are running in a transactional context. 

 In CdmRepository using `factory.openSession()` is plain wrong, the HibernateTransactionManger should be used instead. 

Back