Pergunta

I was curious if it is possible to add a SQL header comment to the sql generated by the hbm2ddl output.

Specifically, it would be nice if I could add generated version strings to the Dialect object that would be output to the generated .sql file.

public static MyDialect extends MySQLDialect {
 // what method do I @Override to generate the comment?
}
Foi útil?

Solução

The answer (to my own question) is that you cannot currently do this. The current version of hibernate (version 4.alpha 03/2011). Their github master SchemaExporter class (https://github.com/hibernate/hibernate-core/blob/master/hibernate-core/src/main/java/org/hibernate/tool/hbm2ddl/SchemaExport.java) only outputs two things to the file 1) the drop table commands then 2) the table creation commands.

If I get time maybe I'll add the feature. The idea is that we could add database versioning to the generated script as a comment header.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top