Joined: Mon Feb 21, 2005 5:42 pm Posts: 10
|
public boolean findUserName(String uname){
SessionFactory instance = Singleton.getPersistenceManager();
boolean result = false;
try {
Session session = instance.openSession();
Transaction tx = session.beginTransaction();
Query q = session.createQuery("from UserDirectory d where d.username = :uname");
q.setParameter("uname", uname);
result = q.list().isEmpty();
tx.commit();
session.close();
} catch (HibernateException e) {
e.printStackTrace();
}
return result;
}
And I receive the following error
net.sf.hibernate.QueryException: in expected: d [from UserDirectory d where d.username = :uname]
at net.sf.hibernate.hql.FromParser.token(FromParser.java:102)
at net.sf.hibernate.hql.ClauseParser.token(ClauseParser.java:87)
at net.sf.hibernate.hql.PreprocessingParser.token(PreprocessingParser.java:123)
at net.sf.hibernate.hql.ParserHelper.parse(ParserHelper.java:29)
at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:149)
at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:138)
at net.sf.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:294)
at net.sf.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:1562)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1533)
at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:39)
at com.users.core.UserDirectory.findUserName(UserDirectory.java:136)
at com.users.core.UserDirectory.main(UserDirectory.java:176)
Any idea?
King Regards!
Natalia
|
|