在Play Framework中使用SchemaExport
在Play Framework 1.2.5上使用Jpa + Hibernate作为ORM,我想以编程方式调用Hibernate工具SchemaExport。 我试过这段代码:
Ejb3Configuration cfg = getPlayEjb3Configuration(); Configuration configuration = cfg.getHibernateConfiguration(); try { SchemaExport se = new SchemaExport(configuration); se.setHaltOnError(true); se.setDelimiter(";").setFormat(true); se.execute(true, false, false, false); } catch(Exception e) { … }
其中getPlayEjb3Configuration()
是play框架JPAPlugin.onApplicationStart()
的“副本”。
我总是获得'no datasource provided'
exception消息。 我尝试在静态引用(修改播放框架)中保留配置而没有区别。
如何从play框架中获取正确的Ejb3Configuration / HibernateConfiguration? 还有其他方法可以调用SchemaExport吗?
我找到了创建SchemaExport的解决方案:
Connection connection = ...; SchemaExport se = SchemaExport(configuration, connection);
一切正常。
- Spring REST,JSON“无法处理托管/后向引用’defaultReference’”415不支持的媒体类型
- MySQL / Hibernate – 如何调试不断丢弃的MySQL池连接?
- 在hibernate中合并父节点后获取子ID
- 如何使用hibernate工具生成带注释的域对象
- Hibernateexception_ $$ _ javassist_0无法强制转换为javassist.util.proxy.Proxy
- 自弃用以来替换@SequenceGenerator
- 每个实体hibernate两个表
- LazyInitializationException,同时使用TestNG对Spring中使用的Hibernate实体类进行unit testing
- 如何使用Hibernate逆向工程工具生成或以进行反向关联?