Olá,
peguei esse exemplo na internet pra criar o banco mysql e automaticamente suas tabelas
e tentei adaptar pra jpa …não funcionou alguém já fez isso …
abs
import net.sf.hibernate.HibernateException;
import net.sf.hibernate.cfg.Configuration;
import net.sf.hibernate.tool.hbm2ddl.SchemaExport;
public class ExportarSchema {
public static void main(String[] args) throws HibernateException {
try {
Configuration cfg = new Configuration().configure("/teu/pacote/hibernate.cfg.xml");
SchemaExport schemaExport = new SchemaExport(cfg);
schemaExport.create(true,true);
} catch (Exception he) {
he.printStackTrace();
}
}
}
o que tentei fazer em JPA …tento criar o banco de dados e depois as tabelas será que da
pra fazer isso usando JPA utilizando Hibernate ???
se alguém puder me ajduar agradeceria…abs
public static void main(String[] args) throws Exception {
org.apache.log4j.BasicConfigurator.configure();
manager = PersistenceServiceFactory.getInstance().getManager();
Session object =(Session) manager.getDelegate();
Configuration cfg = new Configuration().configure("/META-INF/persistence.xml");
SchemaExport schemaExport = new SchemaExport(cfg);
schemaExport.create(true,true);
}