August 2017
Beginner to intermediate
370 pages
8h 37m
English
The following code represents the implementation for the UserDAO interface. In the code, note some of the following which will be required to be mocked for testing DAO objects in isolation:
@Repository@Transactionalpublic class UserDAOImpl implements UserDAO { private SessionFactory sessionFactory; @Autowired public UserDAOImpl(SessionFactory sessionFactory) { this.sessionFactory = sessionFactory; } @Override public List<User> findByEmail(String email) { Session session = this.sessionFactory.getCurrentSession(); TypedQuery<User> query = session.getNamedQuery("findByEmail"); query.setParameter("email", email); return query.getResultList(); }}
The following code represents ...
Read now
Unlock full access