How does hibernate view automatically generated table creation statements on the console?

Source: Internet
Author: User

Hibernate automatically creates a table by configuring <property name = "show_ SQL"> true </property> and <property name = "hbm2ddl. after auto "> Create </property>, You can automatically create a table and display the statement for inserting data on the console. However, the table creation statement cannot be displayed, this is because hibernate built-in log environment slf4j-api interface implementation jar package slf4j-nop-1.5.8.jar is not perfect, slf4j-api interface implementation method is many, to display the table creation statement here you need to use the jar package of log4j to implement the slf4j-api interface, because log4j cannot directly implement the slf4j-api interface also need a converter slf4j-log4j12-1.5.8.jar.

 

Therefore, you only need to perform the following operations to display the table creation Statement on the console:

1. Remove original slf4j-nop-1.5.8.jar to add log4j-1.2.15.jar

2. Add the converter slf4j-log4j12-1.5.8.jar

3. Of course you must also put the interface: slf4j-api-1.5.8.jar

4. Find the file log4j. properties under the directory hibernate-distribution-3.6.0.Final-dist \ hibernate-distribution-3.6.0.Final \ project \ etc, copy to the src directory of the project and open,

You can find the statement: log4j.logger.org. hibernate. tool. hbm2ddl = debug, which is used to display the configuration of DDL statements. Other configurations are used to display other information. If not, comment out the statements.

5. Run the program to view the table creation statements printed on the console.

Note: The slf4j-log4j12-1.5.8.jar and slf4j-api-1.5.8.jar are in the same slf4j official download version folder

Download Website:

Http://www.slf4j.org/dist/

Http://logging.apache.org/log4j/1.2/download.html

 

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.