I had the same problem a few days ago. Anyway the
hbm2dd.auto=create/update only is used for development (for deploying
you'll need the actual queries Hibernate executes), so I've wrote a
small program that creates hibernate Configuration object and then
dumps the update script you should include in evolutions/N.sql.
package test;
import java.util.Properties;
import models.Comment;
import models.Hotel;
import org.hibernate.cfg.Configuration;
import org.hibernate.tool.hbm2ddl.SchemaUpdate;
public class ExportSchema {
public static void main(String[] args) {
// TODO: configure log4j so that it doesnt't log hibernates info messages
// BasicConfigurator.configure();
Configuration conf = new Configuration();
conf.addAnnotatedClass(Hotel.class);
conf.addAnnotatedClass(Comment.class);
Properties hibernateProperties = new Properties();
// TODO: read some of these properties from application.conf
hibernateProperties.put("hibernate.hbm2ddl.auto", "");
hibernateProperties.put("hibernate.show_sql", "true");
hibernateProperties.put("hibernate.dialect",
"org.hibernate.dialect.PostgreSQLDialect");
hibernateProperties.put("hibernate.connection.driver_class",
"org.postgresql.Driver");
hibernateProperties.put("hibernate.connection.url",
"jdbc:postgresql://localhost/HotelApp");
hibernateProperties.put("hibernate.connection.username", "rbigio");
hibernateProperties.put("hibernate.connection.password", "rbigio");
conf.setProperties(hibernateProperties);
SchemaUpdate update = new SchemaUpdate(conf);
// to system.out, but not to the database
update.execute(true, false);
}
}
You could with some small changes enhance this class to fetch all your
entities from your models package.
Hope this helps you,
Martín