【发布时间】:2019-02-21 14:57:24
【问题描述】:
我最近将 Hibernate 从 4.3.7 更新到 5.4.1,SchemaExport API 从 5.1 开始发生了变化。此代码现在显示编译问题(在SchemaExport 构造函数和execute 方法上)。
/**
* Method to generate a SQL script which aim is to create SQL tables for the
* entities indicated as parameters.
*/
private void generateScript(Class<?>... classes) {
Configuration configuration = new Configuration();
configuration.setProperty(Environment.DIALECT, entityManagerFactory.getProperties().get(DIALECT_PROPERTY).toString());
for (Class<?> entityClass : classes) {
configuration.addAnnotatedClass(entityClass);
}
SchemaExport schemaExport = new SchemaExport(configuration);
schemaExport.setDelimiter(SCRIPT_DELIMITER);
schemaExport.setOutputFile(getScriptPath());
schemaExport.setFormat(true);
boolean consolePrint = false;
boolean exportInDatabase = false;
schemaExport.execute(consolePrint, exportInDatabase, false, true);
}
我已经看到与此问题相关的其他问题,但没有足够具体的内容来帮助我重写此函数。
【问题讨论】:
标签: java hibernate schemaexport