In Hibernate 4.x, I used to generate and export the schema as defined in annotated entities as follows (using Spring to find annotated entities on the class path):
The new bootstrap API allows for many customizations, but assuming you don't need those, the shortest invocation would look like that, applying default values for service registries and all the settings:
Metadata metadata = new MetadataSources()
.addAnnotatedClass( MyEntity.class )
.build();
new SchemaExport( (MetadataImplementor) metadata )
.setOutputFile( "my-statements.ddl" )
.create( Target.NONE );
Update: Providing example for applying configuration propperties
There are several ways to inject properties for connection URL, dialect etc. E.g. you could provide a file hibernate.properties or you use a service registry customized with the required settings:
StandardServiceRegistry registry = new StandardServiceRegistryBuilder()
.applySetting( "hibernate.connection.url", "jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1" )
.build();
Metadata metadata = new MetadataSources( registry )
.build();