卡里姆(Kariem)走在正确的道路上,但让我尝试澄清一下。
假设您具有普通的JPA标准配置,除了classpath上的Hibernate
jars外,没有任何Hibernate特定的配置。如果您以J2SE引导模式运行,那么您已经有一些类似于Java或Spring配置等的代码:
Map<String, Object> props = getJPAProperties();EntityManagerFactory emf = Persistence.createEntityManagerFactory("persistence-unit-name", props);要运行SchemaUpdate,只需使用以下代码即可:
Map<String, Object> props = getJPAProperties();Ejb3Configuration conf = new Ejb3Configuration().configure("persistence-unit-name", props);new SchemaUpdate(conf.getHibernateConfiguration()).execute(true, false);我不确定这在容器环境中如何运行,但是在简单的J2SE或Spring类型的配置中,仅此而已。



