• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

HQL create & drop table queries

 
Ranch Hand
Posts: 629
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ram kovis:
you can do it in Hibernate.cfg.xml




Nice... Thanks Ram
 
reply
    Bookmark Topic Watch Topic
  • New Topic