public Member findById(Long id) {
return em.find(Member.class, id);
}
public Member findByEmail(String email) {
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Member> criteria = cb.createQuery(Member.class);
Root<Member> member = criteria.from(Member.class);
// Swap criteria statements if you would like to try out type-safe criteria queries, a new
// feature in JPA 2.0
// criteria.select(member).where(cb.equal(member.get(Member_.name), email));
criteria.select(member).where(cb.equal(member.get("email"), email));
return em.createQuery(criteria).getSingleResult();
}