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.  [ 3 posts ] 
Author Message
 Post subject: Database Schema update using Hibernate Query Language
PostPosted: Thu Mar 26, 2009 7:32 am 
Newbie

Joined: Thu Mar 26, 2009 7:19 am
Posts: 3
Is it possible to alter a table or drop a table using Hibernate Query Language ?

I dont want to use native SQL Query at those querries will be MySql specific.

Through forums I came to know about Hibernate class SchemaUpdate. But it does not
drop a table
drop a column
change a constraint on a column

& I want all of them

Is there any solution other than firing sql querries


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 26, 2009 9:26 am 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
There is no such support in HQL.

But I have successfully been able to programmatically generate org.hibernate.mapping.Table objects. This class has, among other things, the following useful methods:

Code:
Table.sqlCreateString()
Table.sqlDropString()
Table.sqlAlterStrings()


You'll need lots of patience if you want to use this approach since most of it is undocumented. The API is also considered internal and it happens that there are incompatible changes between Hibernate versions.

I don't know how useful it may be but here is a link to the most important part where I am building up the Table object: http://base.thep.lu.se/browser/tags/2.1 ... .java#L800

This Table object is then used in other places, for example: http://base.thep.lu.se/browser/tags/2.1 ... .java#L612


Top
 Profile  
 
 Post subject: Database Schema update using Hibernate Query Language
PostPosted: Fri Mar 27, 2009 1:39 am 
Newbie

Joined: Thu Mar 26, 2009 7:19 am
Posts: 3
Thanks for the fast reply
I will try..


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.