srping 3.1 管理hibernate 持久化对象的配置

1:注解的方式
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"">	
				<property name="packagesToScan">
			<list>
				<value>com.xx.xxx</value>
							</list>
		</property>		
		
		<property name="dataSource">
			<ref bean="dataSource" />
		</property>
		
		<property name="hibernateProperties">
			<props>
				<prop key="hibernate.dialect">org.hibernate.dialect.OracleDialect</prop>
				<prop key="hibernate.show_sql">true</prop>
				<prop key="hibernate.connection.proxool_provider_class">org.hibernate.connection.ProxoolConnectionProvider</prop>
				<prop key="hibernate.dialect">org.hibernate.dialect.OracleDialect</prop>
				<prop key="hibernate.show_sql">true</prop>
				<prop key="hibernate.format_sql">false</prop>
				<prop key="hibernate.use_sql_comments">true</prop>	
					
				<prop key="hibernate.connection.autocommit">true</prop>	  	
		    	
				<prop key="hibernate.cglib.use_reflection_optimizer">true</prop>
				<prop key="hibernate.bytecode.use_reflection_optimizer">true</prop>
		
			</props>
		</property>

2:xml 文式
<!-- 配置Hibernate的sessionFactory -->
	<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">	
		<property name="dataSource">
			<ref bean="dataSource" />
		</property>
		
		<property name="hibernateProperties">
			<props>
				<prop key="hibernate.dialect">org.hibernate.dialect.OracleDialect</prop>
				<prop key="hibernate.show_sql">true</prop>
			</props>
		</property>
		
		<property name="configLocation">
            <value>classpath:conf/hibernate.cfg.xml</value>
        </property>
==========================
hibernate.cfg.xml
<hibernate-configuration>
<session-factory>
	<mapping resource="personal/learn/entity/Manager.hbm.xml" />
	
</session-factory>

</hibernate-configuration>

你可能感兴趣的:(Hibernate,xml,配置管理)