I have entity class User
@Entity(name = "user")
public class User {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int id;
@Column(unique = true, nullable = false)
private String email;
/** skipped **/
And stateless EJB DAO class(I am using jpa/hibernate) with method
@Override
public User findByEmail(String name) {
TypedQuery<User> query = entityManager.createQuery("from User where email= :email", User.class);
query.setParameter("email", name);
return query.getSingleResult();
}
When I execute this method from page(using jsf), it works fine. The problem occurse when I execute this method from WebService EJB bean. I've got following exception
org.hibernate.hql.internal.ast.QuerySyntaxException: User is not mapped [from User where email= :email]
My web service is very simple:
@Stateless(name = "webServiceBean")
@WebService(serviceName = "webService")
public class MyWebService{
@EJB
private UserDao dao;
public String findUser(String email) {
return dao.findByEmail(email);
}
}
Application is deployed on JBoss7. I am using EJB 3.1 and hibernate 4.3
Does anybody knows what is the reason of this exception? And why it occurs only in WebService?