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