To clarify the version, I'm using Hibernate 2.1.7c to connect to MySQL 4.1.7 using Connector/J 3.1.7.
I've tried escaping as \\: and as ::.
I've also tried using different kinds of quotes around the times, double quotes, double single quotes.
None has worked.
I've also tried actually using a named parameter:
Code:
results = session.createSQLQuery("select {event.*} from auditevents event where :whereClause", "event", AuditEvent.class).setString("whereClause", "CONVERT_TZ(event.time, @@session.time_zone, '-08:00') >= '1970-1-2 00:00:00'").list();
Hibernate says it's running the following query:
Hibernate: select event.id as id0_, event.type as type0_, event.time as time0_,
event.username as username0_, event.src_IP_high as src_IP_h5_0_, event.src_IP_low as src_IP_low0_ from auditevents event where ?
But no results are returned.
Surely someone has tried doing queries with times in them before. Any help or suggestions would be greatly appreciated.