<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- properties -->
<!-- 数据库URL -->
<property name="hibernate.connection.url">jdbc:mysql://localhost/tablepersubclass</property>
<!-- 数据库JDBC驱动 -->
<property name="hibernate.connection.driver_class">org.gjt.mm.mysql.Driver</property>
<!-- 数据库用户名 -->
<property name="hibernate.connection.username">root</property>
<!-- 数据库密码 -->
<property name="hibernate.connection.password">hello</property>
<!-- 数据库方言 -->
<property name="dialect">net.sf.hibernate.dialect.MySQLDialect</property>
<!-- 是否日志调试 -->
<property name="show_sql">true</property>
<!-- 是否使用数据库外连接 -->
<property name="use_outer_join">true</property>
<!-- 事务管理 使用JDBC Transaction(使用JTA会报错) -->
<property name="transaction.factory_class">
net.sf.hibernate.transaction.JDBCTransactionFactory
</property>
<!-- 映射文件配置,配置文件名必须包含其相对于根的全路径 -->
<mapping resource="com/model/TItem.hbm.xml" />
</session-factory>
</hibernate-configuration>
把日志调试设置为true,需要log4j.properties配置文件支持
log4j.properties
### direct log messages to stdout ###
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
### direct messages to file hibernate.log ###
#log4j.appender.file=org.apache.log4j.FileAppender
#log4j.appender.file.File=hibernate.log
#log4j.appender.file.layout=org.apache.log4j.PatternLayout
#log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
### set log levels - for more verbose logging change 'info' to 'debug' ###
log4j.rootLogger=warn, stdout
log4j.logger.net.sf.hibernate=info
### log just the SQL
#log4j.logger.net.sf.hibernate.SQL=debug
### log JDBC bind parameters 把这一行改为debug ###
log4j.logger.net.sf.hibernate.type=debug
### log schema export/update ###
log4j.logger.net.sf.hibernate.tool.hbm2ddl=debug
### log cache activity ###
#log4j.logger.net.sf.hibernate.cache=debug
### log jdbc resource acquisition
#log4j.logger.net.sf.hibernate.impl.BatcherImpl=debug
### enable the following line if you want to track down connection ###
### leakages when using DriverManagerConnectionProvider ###
#log4j.logger.net.sf.hibernate.connection.DriverManagerConnectionProvider=trace