Can you help me please with this problem? I want use this method for find the specific nick in my database (It made with Apache Derby). I have used the EntityManager and mapping Persistence - Entity classes from database in the NetBeans.
public static boolean findByNick(String nick) {
List<eng.db.User> ret;
EntityManager em = getEntityManager();
Query q = em.createQuery("SELECT * FROM User u WHERE u.nick =:nick");
q.setParameter("nick", nick);
ret = q.getResultList();
em.close();
boolean hodnota = false;
if (ret.isEmpty()) {
hodnota = true;
}
return hodnota;
}
I get this error:
java.lang.IllegalArgumentException: An exception occurred while creating a query in EntityManager:
Exception Description: Syntax error parsing [SELECT * FROM User u WHERE u.nick =:nick)].
[21, 21] A select statement must have a FROM clause.
[7, 7] The left expression is missing from the arithmetic expression.
[9, 20] The right expression is not an arithmetic expression.
[41, 42] The query contains a malformed ending.
Where is the problem please?