spring3整合hibernate3
1、bean.xml文件
?
?
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN"?
"http://www.springframework.org/dtd/spring-beans-2.0.dtd">
<beans>
?
<bean id="dataSource" value="com.mysql.jdbc.Driver" />
<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/hibernate? ? ? ? ? ? ? ? ? ? useUnicode=true&characterEncoding=UTF-8" /> ?
<property name="user" value="root" />
<property name="password" value="mysql" />
<property name="maxPoolSize" value="40" />
<property name="minPoolSize" value="1" />
<property name="initialPoolSize" value="1" />
<property name="maxIdleTime" value="20" />
</bean>
?
<bean id="sessionFactory"
ref="dataSource" />
<property name="mappingResources">
<list>
<value>hibernatetest/News.hbm.xml</value>
</list>
</property>
?
<property name="hibernateProperties">
<value>
hibernate.dialect=org.hibernate.dialect.MySQLInnoDBDialect
hibernate.hbm2ddl.auto=update
hibernate.shou_sql=true
hibernate.format_sql=true
</value>
?
</property>
?
</bean>
<bean id="hibernateTemplate" ref="sessionFactory"/>
</bean>
</beans>
?
2、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="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://localhost:3306/hibernate</property>
<property name="connection.useUnicode">true</property>?
? ? ? ? ? ? ? ?<property name="connection.characterEncoding">UTF-8</property>
<property name="connection.username">root</property>
<property name="connection.password">mysql</property>
<property name="hibernate.c3p0.max_size">20</property>
<property name="hibernate.c3p0.min_size">1</property>
<property name="hibernate.c3p0.timeout">5000</property>
<property name="hibernate.c3p0.max_statements">100</property>
<property name="hibernate.c3p0.idle_test_period">3000</property>
<property name="hibernate.c3p0.acquire_increment">2</property>
<property name="hibernate.c3p0.validate">true</property>
<property name="dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>
<property name="hbm2ddl.auto">update</property>
?
<mapping resource="hibernatetest/News.hbm.xml" />
?
</session-factory>
</hibernate-configuration>
?