I'm trying to issue a query (using Hibernate 3.0) to programmatically perform a vacuum on my postgres db, and have scoured the books and web looking for examples of such a query. Been banging my head against the wall on this for way too long... any thoughts, suggestions or "give up, can't do that" would be most welcome. 8-)
I know that this works:
Code:
SQLQuery query = session_.createSQLQuery("DROP TABLE PATIENT");
int count = query.executeUpdate();
But this doesn't:
Code:
SQLQuery query = session_.createSQLQuery("VACUUM ANALYZE");
int count = query.executeUpdate();
Strikes me as odd. Shouldn't Hiberate just pass along the native SQL without judging it? Exceptions I have seen, depending on whether I
try to use JDBC directly or the above technique are:
Code:
org.hibernate.QueryException: addEntity() or addScalar()
must be called on a sql query before executing the
query. [VACUUM ANALYZE]
Thought: How could I addEntity() or addScalar() when I have neither?
What is expected?
Code:
java.lang.UnsupportedOperationException: Update queries
only supported through HQL
Thought: Baffling, considering that "DROP" queries work.[quote][/quote]