This content has been marked as final.
Show 1 reply
-
1. Re: SchemaExport
stephen Dec 19, 2008 9:15 PM (in response to ignacio83.ignacio83.gmail.com)Here's what I use for my annotated entities. Not very elegant, because you need to specify each entity separately, but I haven't found another way yet (but didn't search too hard either).
public static void main(String[] args) { AnnotationConfiguration configuration = new AnnotationConfiguration(); // Select the dialect matching the selected DBMSs //configuration.setProperty("hibernate.dialect", "org.hibernate.dialect.HSQLDialect"); configuration.setProperty("hibernate.dialect", "org.hibernate.dialect.Oracle9Dialect"); // Add all root packages that contain entities configuration.addPackage("com.acme.foo.model"); // Add each entity configuration.addAnnotatedClass(ContactData.class); // ... configuration.addAnnotatedClass(User.class); // Dump formated SQL to console and file SchemaExport schemaExport = new SchemaExport(configuration); schemaExport.setOutputFile("schema.sql"); schemaExport.setFormat(true); schemaExport.setDelimiter(";"); schemaExport.execute(true, // write schema to output false, // do not export to DB false, // no drop statements true// only create statements ); }