简体   繁体   中英

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. 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. Perhaps through the hibernate properties?

You can give a try by setting the hibernate.hbm2ddl.import_files property to an empty string.

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 :

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

M.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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