[Hibernate]springとHibernateは配置ファイルを統合します.


Hibernateフレームとspring統合に関する構成:ファイル名:appication Contact.xml

<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
	xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
	xsi:schemaLocation="http://www.springframework.org/schema/beans 
	http://www.springframework.org/schema/beans/spring-beans.xsd
	http://www.springframework.org/schema/context
	http://www.springframework.org/schema/context/spring-context.xsd
	http://www.springframework.org/schema/aop
	http://www.springframework.org/schema/aop/spring-aop.xsd
	http://www.springframework.org/schema/tx 
	http://www.springframework.org/schema/tx/spring-tx.xsd">
	
	
	<context:property-placeholder location="classpath:jdbc.properties"/>
	
	
	<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
		<property name="jdbcUrl" value="${jdbc.url}"/>
		<property name="driverClass" value="${jdbc.driver.class}"/>
		<property name="user" value="${jdbc.username}"/>
		<property name="password" value="${jdbc.password}"/>
	bean>
	
	
	<bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
		<property name="dataSource" ref="dataSource"/>
		
		<property name="hibernateProperties">
			<props>
				
				<prop key="hibernate.show_sql">trueprop>
				
				<prop key="hibernate.hbm2ddl.auto">updateprop>
			props>
		property>
		
		<property name="packagesToScan">
			<list>
				<value>com.csdn.pojovalue>
			list>
		property>
	bean>
	
	
	<bean id="transactionManager" class="org.springframework.orm.hibernate5.HibernateTransactionManager">
		<property name="sessionFactory" ref="sessionFactory"/>
	bean>
	
	
	<tx:annotation-driven transaction-manager="transactionManager"/>
	
	
	<context:component-scan base-package="com.csdn"/>
beans>