| Author |
Query error
|
Natalia Lopez
Ranch Hand
Joined: Feb 17, 2005
Posts: 41
|
|
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
|
 |
Prakash Jebaraj
Greenhorn
Joined: Mar 14, 2005
Posts: 5
|
|
Hi, Check whether you have added UserDirectory in the configuration. Regards, Prakash Jebaraj
|
 |
Natalia Lopez
Ranch Hand
Joined: Feb 17, 2005
Posts: 41
|
|
Hi I add the class UserDirectory on my userDirectorydb.cfg.xml that is like the hibernate.cfg.xml and contains something like <hibernate-configuration> <session-factory> <property name="connection.driver_class">org.gjt.mm.mysql.Driver</property> <property name="connection.url">jdbc:mysql://localhost/userDirectoryNews</property> <property name="connection.username">news</property> <property name="connection.password">news</property> <property name="dialect">net.sf.hibernate.dialect.MySQLDialect</property> <property name="use_outer_join">true</property> <property name="transaction.factory_class">net.sf.hibernate.transaction.JDBCTransactionFactory</property> <property name="show_sql">true</property> <!-- Mapping files --> <mapping resource="com/users/core/UserDirectory.hbm.xml" /> </session-factory> UserDirectory.hbm.xml is on the same folder as UserDirectory.java King regards Natalia
|
 |
 |
|
|
subject: Query error
|
|
|