简体   繁体   中英

Execute my own scripts on Hibernate Schema Update takes place

I'm trying to include my own schema changes (such as varchar to text and create Index) just before entities get bound, just like Hibernate does the schema update. It is ideal if I can include my own custom SQLs in hibernate's schema update itself. For instance by extending an existing hibernate class and allowing application to use mine instead of built-in one.

org.hibernate.internal.SessionFactoryImpl is final.

May be by implementing my own org.hibernate.tool.schema.spi.SchemaMigrator. Anyone tried this before?

BTW, I'm using spring boot v1.4.0.M3, in case it has any specific dependencies, I don't think so.

Cheers!

Spring Boot has a JDBC initializer, it runs .sql scripts at startup. I would recommend using Flyway, it keeps track of the version of your database and which scripts have been executed.

http://docs.spring.io/spring-boot/docs/current/reference/html/howto-database-initialization.html#howto-initialize-a-database-using-spring-jdbc

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