Hi .
Having a problem with createCriteria.
My Hibernate connection and sessions are ok. The only problem is hat I cannot use Example.createCriteria and get an error that: could not execute query.
I have also tried to type the SQL code between quotes and results in the same error.
Any help will be appreciated.
This is my little java code:
Code:
System.out.println("Debug: Login starting (username: "+username.toString()+"; password: " + password.toString() + ")");
User criteria = new User();
criteria.setUserName(username.toString());
criteria.setUserPassword(password.toString());
System.out.println("Debug: Username in object: " + criteria.getUserName());
System.out.println("Debug: HIBERNATE: Open session");
Session session = sessions.openSession();
System.out.println("Debug: HIBERNATE: Begin transaction");
Transaction tx = session.beginTransaction();
System.out.println("Debug: HIBERNATE: Craeting criteria");
Criteria crit = session.createCriteria(User.class);
System.out.println("Debug: HIBERNATE: Creating SQL code");
List result = crit.add( Example.create(criteria)).list();
session.close();
System.out.println("Debug: Results: " + result.size());
// tx.commit();
return result;
The error:
Code:
Hibernate: select this_.user_id as user1_0_, this_.user_name as user2_0_0_, this_.user_password as user3_0_0_, this_.user_group_id as user4_0_0_ from user this_ where (this_.user_name=? and this_.user_password=?)
17-jun-2005 19:44:28 org.hibernate.util.JDBCExceptionReporter logExceptions
WARNING: SQL Error: 335544569, SQLState: HY000
17-jun-2005 19:44:28 org.hibernate.util.JDBCExceptionReporter logExceptions
SEVERE: GDS Exception. 335544569. Dynamic SQL Error
SQL error code = -104
Token unknown - line 1, char 140
user
17-jun-2005 19:44:28 org.hibernate.util.JDBCExceptionReporter logExceptions
WARNING: SQL Error: 335544569, SQLState: HY000
17-jun-2005 19:44:28 org.hibernate.util.JDBCExceptionReporter logExceptions
SEVERE: GDS Exception. 335544569. Dynamic SQL Error
SQL error code = -104
Token unknown - line 1, char 140
user
Exception in thread "AWT-EventQueue-0" org.hibernate.exception.GenericJDBCException: could not execute query
....