retromuz
retromuz

Reputation: 799

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!

Upvotes: 0

Views: 507

Answers (1)

Jeff
Jeff

Reputation: 1955

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

Upvotes: 1

Related Questions