-->
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.  [ 6 posts ] 
Author Message
 Post subject: How to delete Database tables using Hibernate
PostPosted: Mon Jul 25, 2005 12:41 am 
Beginner
Beginner

Joined: Mon Jul 25, 2005 12:35 am
Posts: 24
Location: Sri Lanka
Hi,

I can create database tables easily. Can somebody tell me how to delete table using Hibernate?

I really appreciate your help,

Thank you.
Thilina.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 25, 2005 1:57 am 
Newbie

Joined: Tue Jul 05, 2005 11:47 pm
Posts: 15
Location: Argentina
I guess that the most efficient way is to ask for a JDBC connection to the session and issue a delete.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 25, 2005 2:08 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Come on guys, why not read the reference documentation. Hibernate 3.0 supports mass operations and 3.1 supports mass deletes. Steve even blogged about it.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 25, 2005 2:09 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Sorry, wrong answer. You are not looking for mass deletes, but for "drop table" DDL. SchemaExport can produce that, read the documentation.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 25, 2005 2:32 am 
Beginner
Beginner

Joined: Mon Jul 25, 2005 12:35 am
Posts: 24
Location: Sri Lanka
Hi,

Thank you for your responses...

I use following, but it gives some errors,

List systemUsers = session.createQuery("drop table hse_Customer_Group").list();

Error message is:

org.hibernate.hql.ast.QuerySyntaxError: unexpected token: drop near line 1, column 1 [drop table hse_Customer_Group]

How should I solve this?

Thank you.
Thilina.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 25, 2005 3:47 am 
Expert
Expert

Joined: Thu Dec 04, 2003 12:36 pm
Posts: 275
Location: Bielefeld, Germany
Use the SchemaExport.

http://www.hibernate.org/hib_docs/v3/re ... guide-s1-3

Best regards
Sven


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