try {
EntityManagerFactory emf = null;
EntityManager em = null;
emf = Persistence.createEntityManagerFactory("Stlogin");
em = emf.createEntityManager();
Query query = em
.createQuery("SELECT usuario, senha FROM Usuario WHERE usuario = :usuario and senha = :senha");
query.setParameter("usuario", "123");
query.setParameter("senha", "123");
Usuario user = (Usuario) query.getSingleResult();
System.out.println(user.getUsuario());
System.out.println(user.getSenha());
} catch (NoResultException e) {
System.out.println(e.getMessage());
} catch (NonUniqueResultException e) {
System.out.println(e.getMessage());
} catch (Exception e) {
System.out.println(e.getMessage());
}
Erro:
[EL Info]: 2011-02-24 13:14:13.626--ServerSession(809606405)--EclipseLink, version: Eclipse Persistence Services - 2.1.2.v20101206-r8635
[EL Info]: 2011-02-24 13:14:14.033--ServerSession(809606405)--file:/D:/Desenvolvimento/Java Web/SistemaLogin/build/classes/_Stlogin login successful
An exception occurred while creating a query in EntityManager:
Exception Description: Syntax error parsing the query [SELECT usuario, senha FROM Usuario WHERE usuario = :usuario and senha = :senha], line 1, column 35: syntax error at [WHERE].
Internal Exception: MismatchedTokenException(79!=80)
Alguém sabe porque esse erro?
Obrigado.