hibernate配置文件详解:
ORM元素:
根元素:
class元素:
id元素:
property元素:
hibernate主配置:
必选属性配置(5个):
可选属性配置(3个):
元数据引入配置:(这一条经常被遗忘)
//hibernate.cfg.xml <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <!-- 必需项 --> <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property> <property name="hibernate.connection.url">jdbc:mysql:///crm</property> <property name="hibernate.connection.username">root</property> <property name="hibernate.connection.password">123456</property> <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property> <!-- 非必需项 --> <property name="hibernate.show_sql">true</property> <property name="hibernate.format_sql">true</property> <mapping resource="domain/Customer.hbm.xml"/><!-- 包名+类名 --> </session-factory> </hibernate-configuration>