This paper mattered meters along
This address: http://blog.csdn.net/sushengmiyan/article/details/50534361
We all know that we can use Hibernate's metadata metadata to generate the table structure, but in general, we just rely on hibernate automatic generation is not enough, we look forward to using their own SQL script, you hibernate automatically execute that script can. So hibernate support does not support it? The answer is yes! .
We only need to do the following settings:
<property name= "Hibernate.hbm2ddl.auto" value= "create"/> <property name= "Hibernate.hbm2ddl.import_ Files_sql_extractor "value=" Org.hibernate.tool.hbm2ddl.MultipleLinesSqlCommandExtractor "/><property name=" Javax.persistence.schema-generation.database.action " value=" drop-and-create "/><property name=" Javax.persistence.schema-generation.create-source "value=" script "/><property name=" Javax.persistence.schema-generation.create-script-source "value=" Meta-inf/complexschemas/loadscript.sql.txt "/ >
Explain the following:
1.hibernate.hbm2ddl.auto Setting the database table structure every time
2.hibernate.hbm2ddl.import_files_sql_extractor Open script multi-line execution.
3.javax.persistence.schema-generation.database.action database is drop and regenerate every time
4.javax.persistence.schema-generation.create-source generated in a custom script
The location of the 5.javax.persistence.schema-generation.create-script-source script.
Reference:
Http://docs.oracle.com/javaee/7/tutorial/persistence-intro005.htm
Hibernate replaces annotations or auto-generated table structures in XML files using custom scripts