我有下一个方法
public List<String> getCreateTableStatements(final Configuration configuration) {
try
{
final SchemaExport schemaExport = new SchemaExport(configuration);
// it's a pitty SchemaExport.createSQL is not accessible from outside, but I (juergen) consider the reflection way being better than going through the filesystem.
final Field createSqlField = schemaExport.getClass().getDeclaredField("createSQL"); //$NON-NLS-1$
createSqlField.setAccessible(true);
String[] createSql = (String[]) createSqlField.get(schemaExport);
return Arrays.asList(createSql);
} catch(Exception e)
{
throw new DataSourceException(e);
}}
但是在新版本的hibernatenew SchemaExport(configuration)
中不再存在并且这 schemaExport.getClass().getDeclaredField("createSQL")
也不起作用,因为createSql
没有找到。我该如何重写这个方法以对应新版本的hibernate?我提到我正在从 hibernate3 升级到 hibernate 5.6