File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Object Relational Mapping and the fly likes alter table command Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "alter table command" Watch "alter table command" New topic

alter table command

Arun R. S. Chandran
Ranch Hand

Joined: Oct 08, 2008
Posts: 81

I am using hibernate. Is there any query we can use for altering a table?
If it is possible please reply me.

Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

This is not something you should be doing with Hibernate. If you alter a table, you invalidate any object mapped to it.

Hibernate does support dynamically creating and updating scheama at start up. Have a look at the hbm2ddl properity in the configuration docs.

Hibernate also allows you to run native SQL (check the Session class's JavaDocs). But like I said, not a safe thing to do if the table is mapped.

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Arun R. S. Chandran
Ranch Hand

Joined: Oct 08, 2008
Posts: 81
Thanks Paul
I agree. Here's the link:
subject: alter table command
It's not a secret anymore!