hibernate配置文件

hibernate配置文件:hibernate.cfg.xml
<?xml version="1.0" encoding="gbk"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
  <session-factory>
  	<!-- hiberante 使用连接池 -->
  	<property name="connection.datasource">java:comp/env/jdbc/testdbcp</property>   
  	<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
  	
  	
  	<!-- hibernate自带链接 -->
  	<!-- 
    <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
    <property name="hibernate.connection.url">jdbc:mysql://127.0.0.1/sshWithDBCP</property>
    <property name="hibernate.connection.username">root</property>
    <property name="hibernate.connection.password">root</property>
    <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
     -->
    <property name="hibernate.show_sql">true</property>
    <property name="hibernate.hbm2ddl.auto">update</property>
    <mapping resource="com/max/model/Order.hbm.xml"/>
    <mapping resource="com/max/model/User.hbm.xml"/>
  </session-factory>
</hibernate-configuration>


spring中配置读取hibernate配置文件创建SF:
<bean id="sessionFactory"
		class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
		<property name="configLocation">
			<value>classpath:hibernate.cfg.xml</value>
		</property>
	</bean>

你可能感兴趣的:(spring,Hibernate,mysql,xml,jdbc)