hibernate配置文件——xml和注解的方式
XML方式
<!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.dialect"> org.hibernate.dialect.MySQL5Dialect</property> <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property> <property name="hibernate.connection.url">jdbc:mysql://127.0.0.1:3306/flower</property> <property name="hibernate.connection.username">root</property> <property name="connection.password">1213265442</property> <property name="hibernate.hbm2ddl.auto">update</property> <property name="format_sql">true</property> <property name="show_sql">true</property> <property name="hibernate.current_session_context_class">thread</property> <mapping resource="com/jikexueyuan/entity/Assess.hbm.xml"/> <mapping resource="com/jikexueyuan/entity/Catalog.hbm.xml"/> <mapping resource="com/jikexueyuan/entity/ConsumeDetaileInfo.hbm.xml"/> <mapping resource="com/jikexueyuan/entity/ConsumeOrder.hbm.xml"/> <mapping resource="com/jikexueyuan/entity/Flower.hbm.xml"/> <mapping resource="com/jikexueyuan/entity/OrderForm.hbm.xml"/> <mapping resource="com/jikexueyuan/entity/ShoppingCart.hbm.xml"/> <mapping resource="com/jikexueyuan/entity/User.hbm.xml"/> <mapping resource="com/jikexueyuan/entity/UserDetail.hbm.xml"/> </session-factory> </hibernate-configuration> <!-- <mapping resource="com/jikexueyuan/entity/Poets.hbm.xml"/> <mapping resource="com/jikexueyuan/entity/Message.hbm.xml"/> -->
注解方式
<!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.dialect"> org.hibernate.dialect.MySQL5Dialect</property> <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property> <property name="hibernate.connection.url">jdbc:mysql://127.0.0.1:3306/user</property> <property name="hibernate.connection.username">root</property> <property name="connection.password">1213265442</property> <property name="hibernate.hbm2ddl.auto">update</property> <property name="format_sql">true</property> <property name="show_sql">true</property> <property name="hibernate.current_session_context_class">thread</property> <mapping class="com.jikexueyuan.entity.User"/> </session-factory> </hibernate-configuration>