-->
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.  [ 4 posts ] 
Author Message
 Post subject: DDL with Hibernate
PostPosted: Wed Dec 27, 2006 6:30 am 
Newbie

Joined: Tue Oct 17, 2006 10:34 am
Posts: 3
Hi forum,

Does Hibernate support DDL statement execution, for eg; create database or create table statements?

I don't think HQL gives direct support for DDL, but can we not invoke Native SQL statements directly from Hibernate in the following way:

Code:
SQLQuery sql = session.createSQLQuery("create database " + dbName);
sql.executeUpdate();


However, in such a case I get an UnsupportedOperationException, because update operations are not allowed with SQLQuery objects!

Thanks in advance.

Regards,
Kumar Iyer.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 27, 2006 6:41 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
I don't recommend using native sql queries to do DDL operations; but in 3.2 it should be possible because here .executeUpdate() is suppored for native queries.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 27, 2006 7:33 am 
Newbie

Joined: Tue Oct 17, 2006 10:34 am
Posts: 3
Hi Max,

If not through Native SQL, how else can you execute DDL statements thru Hibernate?

Regards,
Kumar Iyer


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 27, 2006 7:53 am 
Regular
Regular

Joined: Wed Mar 23, 2005 8:43 am
Posts: 105
Location: Moscow, Russia
You can get plain JDBC Connection from Hibernate Session, and execute DDL statement throuth it.

_________________
Best Regards


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.