August 2017
Beginner to intermediate
370 pages
8h 37m
English
Once the bean definitions get configured, the next step is to autowire SessionFactory in DAO classes. The following code represents how to autowire SessionFactory in DAO classes:
@Repository @Transactional public class UserDAOImpl implements UserDAO { @Autowired private SessionFactory sessionFactory; @Override public List<User> findByEmail(String email) { return this.sessionFactory.getCurrentSession() .createQuery("from User u where u.email = :email") .setString("email", email) .list(); } }
Note some of the following terms in the preceding code:
Read now
Unlock full access