Hibernate replaces annotations or auto-generated table structures in XML files using custom scripts

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.