View Javadoc

1   package se.citerus.dddsample.infrastructure.persistence.hibernate;
2   
3   import org.hibernate.Session;
4   import org.hibernate.SessionFactory;
5   import org.springframework.beans.factory.annotation.Required;
6   
7   /**
8    * Functionality common to all Hibernate repositories.
9    */
10  public abstract class HibernateRepository {
11  
12    private SessionFactory sessionFactory;
13  
14    @Required
15    public void setSessionFactory(final SessionFactory sessionFactory) {
16      this.sessionFactory = sessionFactory;
17    }
18  
19    protected Session getSession() {
20      return sessionFactory.getCurrentSession();
21    }
22  
23  }