I’ve got a MySQL database which contains a table named User. It has two columns. One is named ID, the other is EMAIL. It has more columns but that is irrelevant to the question.
In my DAO-object, I’d like to create a method named findByEmail. It currently looks like this:
@Override
public User findByEmail(String email) {
Object obj = em.createQuery("FROM User WHERE EMAIL LIKE :email").setParameter("email", email).getSingleResult();
User user = (User)obj;
return user;
}
This gives a nullpointer-exception. My guess is, my query is wrong. Can anyone help me out on this one?
Apparently, the MySQL-server was configured to block all remote connections. It now works (with the JPA query supplied by vels4j,
select r FROM User r WHERE r.EMAIL = :email)