简体   繁体   English

在hibernate中关闭import.sql

[英]Turn off import.sql in hibernate

This is an under documented part of hibernate, but if a file named import.sql exists in the root of the class path ('/import.sql') Hibernate will execute the SQL statements read from the file after the creation of the database schema. 这是hibernate中记录不足的部分,但是如果类路径的根目录中存在名为import.sql的文件('/import.sql')将在创建数据库模式后执行从文件读取的SQL语句。 I was wondering if there was a way to turn this off on hibernate. 我想知道是否有办法在休眠时关闭它。 The obvious answer is to change the name from import.sql, but I was wondering if there was another way. 显而易见的答案是从import.sql更改名称,但我想知道是否还有其他方法。 Perhaps through the hibernate properties? 也许通过hibernate属性?

You can give a try by setting the hibernate.hbm2ddl.import_files property to an empty string. 您可以通过将hibernate.hbm2ddl.import_files属性设置为空字符串来尝试。

As you can see in the source code of SchemaExport , tries to load the files specified by the property and returns the DEFAULT_IMPORT_FILE if the configuration does not contains a value : 正如您在SchemaExport的源代码中所看到的,尝试加载属性指定的文件,如果配置不包含值,则返回DEFAULT_IMPORT_FILE:

    this.importFiles = ConfigurationHelper.getString(
            AvailableSettings.HBM2DDL_IMPORT_FILES,
            configuration.getProperties(),
            DEFAULT_IMPORT_FILE
    );

M. M.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM