-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Native SQL vacuum query?
PostPosted: Mon Jan 23, 2006 2:44 pm 
Newbie

Joined: Fri Jan 20, 2006 6:06 pm
Posts: 1
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]


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 23, 2006 4:52 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
nativesql queries does not support anything else than select queries.

why dont you just execute session.connection().executeQuery("blah"); ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.