Spring 配置 Hibernate

	<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
		<property name="configLocation">
			<value>billinghibernate.cfg.xml</value>
		</property>
	</bean>
	<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
		<property name="sessionFactory">
			<ref bean="sessionFactory"></ref>
		</property>
	</bean>
	<bean id="CatBillingTempBillingRecordDAOProxy" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
		<property name="proxyInterfaces">
			<list>
				<value>com.playphone.billing.hibernate.ICatBillingTempRecordDAO</value>
			</list>
		</property>
		<property name="target">
			<ref bean="CatBillingTempBillingRecordDAO" />
		</property>
		<property name="transactionAttributes">
			<props>
				<prop key="save">PROPAGATION_REQUIRED,-java.lang.Exception</prop>
				<prop key="delete">PROPAGATION_REQUIRED,-java.lang.Exception</prop>
				<prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>
				<prop key="getUnbilledUsers">PROPAGATION_REQUIRED</prop>
			</props>
		</property>
		<property name="transactionManager">
			<ref bean="transactionManager" />
		</property>
	</bean>

	<bean id="CatBillingTempBillingRecordDAO" class="com.playphone.billing.hibernate.CatBillingTempBillingRecordDAO">
		<property name="sessionFactory">
			<ref bean="sessionFactory" />
		</property>
	</bean>
<bean id="recurrentBillingBean" class="com.playphone.billing.recurrent.RecurrentBillingBean">
	    <property name="tempBillingRecordDAO">
			<ref bean="CatBillingTempBillingRecordDAOProxy"/>
		</property>
</bean>

 在JAVA类中的调用如下:

public class RecurrentFetchBean {

	private Log log = LogFactory.getLog(RecurrentFetchBean.class);
	private String CHECK_AFTER_FETCH = "ON";
	
	private ICatBillingTempRecordDAO tempBillingRecordDAO;
	
	//Added by Tahir for Billing Activity
	private static final String PROCESS_NAME = "Recurrent Fetch Service";
	
	public ICatBillingTempRecordDAO getTempBillingRecordDAO() {
		return tempBillingRecordDAO;
	}

	public void setTempBillingRecordDAO(ICatBillingTempRecordDAO tempBillingRecordDAO) {
		this.tempBillingRecordDAO = tempBillingRecordDAO;
	}

	
	/**
	 * constructor
	 */
	public RecurrentFetchBean() {
	}
 

你可能感兴趣的:(spring,Hibernate,bean,xml,orm)