I have the following entity, Customer
:
@Entity
@Table(name = "customer")
@NamedQueries({
@NamedQuery(name = "**Customer.findByEmail**", query = "SELECT c FROM Customer c WHERE c.email = :email"),
(...)
And the following session facade method:
public List<Customer> GetPorEmail(String match){
List customers = em.createNamedQuery("Customer.findByEmail").setParameter("email", match).getResultList();
return customers;
}
When I call the method, the result is always java.lang.NullPointerException
.
I am certain that there are emails matching the match
in my DB.
How is this caused and how can I solve it?
I think your EntityManager is null. Please check whether you are injecting EntityManager reference properly and its not null.
Regards,