Use the Hibernate SchemaExport class. It will create scripts like this:
Code:
drop table if exists User
create table User
(id integer not null auto_increment,
password varchar(255),
primary key (id))
It's easy to use if you have a Configuration object already configured, and you can control it programatically. Here's a tutorial I put together on verifying your Hibernate3 configuration with the SchemaExport:
http://www.hiberbook.com/HiberBookWeb/learn.jsp?tutorial=02validatingthehibernateenvironmentCode:
public static void main(String args[]) {
AnnotationConfiguration config =
new AnnotationConfiguration();
config.addAnnotatedClass(User.class);
config.configure();
new SchemaExport(config).create(true, true);
}
Here's the Hibernate tutorial link from which this code originates. Check it out!
[url]
http://www.hiberbook.com/HiberBookWeb/learn.jsp?tutorial=02validatingthehibernateenvironment[/url]