Hierarchy Developer's Guide for Oracle Self-Service E-Billing > Extending Advanced Hierarchy Manager Use Cases > Creating New Types of Business Objects to Work with Hierarchy Manager >

Making Business Objects Transactional Aware


To ensure that your OMF object supports flexible transaction management, each object's DAO layer is wrapped in either the Spring framework's transaction proxy, or it is managed through the spring hibernate transaction interceptor. Here are some examples:

<bean id="ServiceAgreementDimDaoTarget"
class="com.edocs.common.omf.serviceagreement.olap.ServiceAgreementDimDao"
singleton="true">
<property name="sessionFactory">
<ref bean="OLAPSessionFactory"/></property>
</bean>
<bean id="ServiceAgreementDaoTarget"
class="com.edocs.common.omf.serviceagreement.ServiceAgreementDao"
singleton="true">
<property name="sessionFactory"><ref
bean="OMFSessionFactory"/></property>
<property name="enableOLAPSync"><value>true</value></property>
<property name="serviceDimDao"><ref
bean="ServiceAgreementDimDaoTarget"/>
</property>
</bean>
<bean id="ServiceAgreementDao"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" singleton="true">
<property name="proxyTargetClass"><value>true</value></property>
<property name="transactionManager"><ref bean="TransactionManager"/></property>
<property name="target"><ref bean="ServiceAgreementDaoTarget"/></property>
<property name="transactionAttributes">
<props>
<prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="*">PROPAGATION_REQUIRED,-HierarchyException,-DataStoreException</prop>
</props>
</property>
</bean>

The OMFSessionFactory and TransactionManager beans are defined in the omf.xma.xml file for OMF module objects as follows. Add your new hbm.xml file into the <list> section:

<bean id="OMFSessionFactory" class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
<property name="dataSource"><ref bean="myDataSource"/></property>
<property name="mappingResources">
<list>
<value>com/edocs/common/omf/chargetype/chargetype.hbm.xml</value>
<value>com/edocs/common/omf/company/company.hbm.xml</value>
<value>com/edocs/common/omf/company/companyprofile.hbm.xml</value>
<value>com/edocs/common/omf/costcenter/costcenter.hbm.xml</value>
<value>com/edocs/common/omf/period/period.hbm.xml</value>
<value>com/edocs/common/omf/flexfieldmap/extfielddef.hbm.xml</value>
<value>com/edocs/common/omf/service/service.hbm.xml</value>
<value>com/edocs/common/omf/serviceagreement/serviceagreement.hbm.xml</value>
<value>com/edocs/common/omf/servicecharge/servicecharge.hbm.xml</value>
<value>com/edocs/common/omf/plan/plan.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties"><ref bean="defaultHibernateProps"/></property>
</bean>

Code Example: Using the JTA Transaction Manager

Specify the TransactionManager using JtaTransactionManager. For example:

<!-- Use JTA Transaction Manager for multiple data sources)-->
<bean id="TransactionManager" class="org.springframework.transaction.jta.JtaTransactionManager">
<property name="transactionManagerName">
<value>javax.transaction.TransactionManager</value>
</property>
<property name="userTransactionName"><value>javax.transaction.UserTransaction</value>
</property>
</bean>

Code Example: Using the Hibernate Transaction Manager

Specify the TransactionManager using HibernateTransactionManager. For example:

<!-- Use Hibernate manage transaction manager for single data source -->

<bean id="TransactionManager"
class="org.springframework.orm.hibernate.HibernateTransactionManager"
singleton="true" lazy-init="default" autowire="default" dependency-check="default">
<property name="sessionFactory"><ref bean="OMFSessionFactory"/></property>
</bean>

Use one transaction manager for all your modules, because Oracle Self-Service E-Billing works with the OLAP database using the JTA transaction manager, and the JTA transaction manager is used by all modules and components. Use the hibernate transaction manager to unit test your code.

Hierarchy Developer's Guide for Oracle Self-Service E-Billing Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Legal Notices.