Read the rules before posting!
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: 2.1.6
Code between sessionFactory.openSession() and session.close():
Name and version of the database you are using: MySQL 4.1.8
The generated SQL (show_sql=true): select persistent0_.uid as uid, persistent0_.timestamp as timestamp, persistent0_.typename as typename from persistentstate persistent0_ where (persistent0_.timestamp<=? )
I'm trying to use batch delete ( session.delete(...) ) to delete a large number of objects. My code looks like this:
Code:
String deleteQueryString = "from " + Database.NAME_OF_STATE + " e where e.timestamp <= ?";
// Delete the requested entries
session.delete(
deleteQueryString,
new Object[] { latestTimestamp },
new Type[] { Hibernate.DATE }
);
latestTimestamp is a Date object. Database.NAME_OF_STATE is my table, "PersistentState". When I look at the SQL generated, however, it comes out both on the console and in the debug log with the "?" parameter still intact:
Quote:
DEBUG [net.sf.hibernate.SQL] select persistent0_.uid as uid, persistent0_.timestamp as timestamp, persistent0_.typename as typename from persistentstate persistent0_ where (persistent0_.timestamp<=? )
None of the entries in the database appear to be affected. Nothing that I've tried seems to make the parameter get substituted. Trying too many parameters throws a "too many parameters" style error, and mismatching the parameter Type throws an appropriate error, so it looks like Hibernate is aware of the parameter, but I'm not really getting whether the parameter isn't getting substituted and the SQL is bad, or if I can't see what the SQL is that's being generated because the substitution is masked on output.
Am I missing something obvious?
Thanks,
- Ert[/quote]