Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HQL create & drop table queries

 
Arjun Reddy
Ranch Hand
Posts: 629
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Can anyone tell me how to create and drop a table in hibernate using HQL? I tried to look it up online but couldn't really find an answer.

Thanks.
[ December 15, 2008: Message edited by: Arjun Reddy ]
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't do it via HQL. If you think about it, its not really a valid thing to want to do. HQL works with mapped objects in a SessionFactory; what you are trying to do is remove the underlying table without removing the mapped object, which is asking for trouble.

You can do this via SQL, since Hibernate allows you to run SQL queries. But I'd think about why you need to do this first. And remember, Hibernate can create tables at start up time which is a more valid place to be performing DDL stuff.
 
Arjun Reddy
Ranch Hand
Posts: 629
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Paul Sturrock:
[QB And remember, Hibernate can create tables at start up time which is a more valid place to be performing DDL stuff.[/QB]


How can this be done Paul?

Thanks.
[ December 17, 2008: Message edited by: Arjun Reddy ]
 
Ram kovis
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can do it in Hibernate.cfg.xml

 
Arjun Reddy
Ranch Hand
Posts: 629
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ram kovis:
you can do it in Hibernate.cfg.xml




Nice... Thanks Ram
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic