• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Spring in CMT MDB

 
sreelakshmi sarma
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

We have a requirement in our project to provide more user friendly error messages when ever a sql exception occurs in the data zone. In order to implement this we have decided to use Spring Database Exception handling. Currently our data zone is implemented using MDB and iBatis for data access. MDB is defined as CMT so i would just like to use spring-ibatis so i can take advantage of spring DataAccessException heirarchy and using Spring AOP for iBatis DAO initialization. My question now is how do i make sure that trasactions are managed by the container and spring doesn't interfere with the transaction management. Again i do want to use Spring transaction management just use spring for other purposes. Is it possible to configure spring in such a way?

This is how i have configured my spring and ibatis config files. Is this the right way of configuring it?

spring-dao.xml


<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

<!-- DataSource -->
<bean id="dataSource"
class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:comp/env/jdbc/dbids" />
<property name="lookupOnStartup" value="false" />
<property name="cache" value="true" />
<property name="proxyInterface" value="javax.sql.DataSource" />
</bean>


<!-- SqlMap Client -->
<bean id="sqlMapClient"
class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="configLocation">
<value>classpath:sql-map-config.xml</value>
</property>
<property name="dataSource">
<ref bean="dataSource" />
</property>
</bean>

<!-- SqlMap Client Template -->
<bean id="sqlMapClientTemplate"
class="org.springframework.orm.ibatis.SqlMapClientTemplate">
<property name="sqlMapClient">
<ref bean="sqlMapClient" />
</property>
</bean>

<bean id="abstractDao" abstract="true">
<property name="sqlMapClient">
<ref bean="sqlMapClient" />
</property>

<property name="exceptionTranslator">
<bean
class="gov.hhs.cms.dbids.dz.persistence.spring.DBidSSqlErrorCodeExceptionTranslator">
<property name="dataSource" ref="dataSource" />
</bean>
</property>

</bean>

<bean id="gov.hhs.cms.dbids.dto.bid.BidTO"
class="gov.hhs.cms.dbids.dz.persistence.ibatis.bid.BidDAO"
parent="abstractDao" />
<bean id="gov.hhs.cms.dbids.bo.bid.BidItem"
class="gov.hhs.cms.dbids.dz.persistence.ibatis.bid.BidItemDAO"
parent="abstractDao" />
<bean id="gov.hhs.cms.dbids.bo.bid.County"
class="gov.hhs.cms.dbids.dz.persistence.ibatis.bid.CountyDAO"
parent="abstractDao" />
<bean id="gov.hhs.cms.dbids.bo.audit.BidAudit"
class="gov.hhs.cms.dbids.dz.persistence.ibatis.audit.BidAuditDAO"
parent="abstractDao" />
<bean id="gov.hhs.cms.dbids.bo.bid.SubContractor"
class="gov.hhs.cms.dbids.dz.persistence.ibatis.bid.SubContractorDAO"
parent="abstractDao" />
<bean id="gov.hhs.cms.dbids.bo.bid.TopItem"
class="gov.hhs.cms.dbids.dz.persistence.ibatis.bid.TopItemDAO"
parent="abstractDao" />
<bean id="gov.hhs.cms.dbids.bo.bid.Model"
class="gov.hhs.cms.dbids.dz.persistence.ibatis.bid.ModelDAO"
parent="abstractDao" />
<bean id="gov.hhs.cms.dbids.dto.bidder.LocationTO"
class="gov.hhs.cms.dbids.dz.persistence.ibatis.bidder.LocationDAO"
parent="abstractDao" />
<bean id="gov.hhs.cms.dbids.bo.bidder.CBALocation"
class="gov.hhs.cms.dbids.dz.persistence.ibatis.bidder.LocationCBADAO"
parent="abstractDao" />
<bean id="gov.hhs.cms.dbids.dto.bidder.SupplierTO"
class="gov.hhs.cms.dbids.dz.persistence.ibatis.bidder.SupplierDAO"
parent="abstractDao" />
<bean id="gov.hhs.cms.dbids.dto.bidder.BidderTO"
class="gov.hhs.cms.dbids.dz.persistence.ibatis.bidder.BidderDAO"
parent="abstractDao" />
<bean id="gov.hhs.cms.dbids.bo.bidder.ContactPerson"
class="gov.hhs.cms.dbids.dz.persistence.ibatis.bidder.ContactPersonDAO"
parent="abstractDao" />
<bean id="gov.hhs.cms.dbids.bo.bidder.KeyPerson"
class="gov.hhs.cms.dbids.dz.persistence.ibatis.bidder.KeyPersonDAO"
parent="abstractDao" />
<bean id="gov.hhs.cms.dbids.bo.bidder.Accreditation"
class="gov.hhs.cms.dbids.dz.persistence.ibatis.bidder.AccreditationDAO"
parent="abstractDao" />
<bean id="gov.hhs.cms.dbids.bo.bidder.AccreditationProductClass"
class="gov.hhs.cms.dbids.dz.persistence.ibatis.bidder.AccreditationProductClassDAO"
parent="abstractDao" />
<bean id="gov.hhs.cms.dbids.bo.bidder.BidderCBA"
class="gov.hhs.cms.dbids.dz.persistence.ibatis.bidder.BidderCBADAO"
parent="abstractDao" />
<bean id="gov.hhs.cms.dbids.bo.bidder.BidderPC"
class="gov.hhs.cms.dbids.dz.persistence.ibatis.bidder.BidderPCDAO"
parent="abstractDao" />
<bean id="gov.hhs.cms.dbids.bo.audit.BidderAudit"
class="gov.hhs.cms.dbids.dz.persistence.ibatis.audit.BidderAuditDAO"
parent="abstractDao" />
<bean id="gov.hhs.cms.dbids.reference.BidCycle"
class="gov.hhs.cms.dbids.dz.persistence.ibatis.reference.BidCycleDAO"
parent="abstractDao" />
<bean id="ReferenceDAO"
class="gov.hhs.cms.dbids.dz.persistence.ibatis.reference.ReferenceDAO"
parent="abstractDao" />
<bean id="StatusDAO"
class="gov.hhs.cms.dbids.dz.persistence.ibatis.status.DBidsStatusDAO"
parent="abstractDao" />
<bean id="LockDAO"
class="gov.hhs.cms.dbids.dz.persistence.ibatis.LockDAO"
parent="abstractDao" />
<bean id="NSCValidationDAO"
class="gov.hhs.cms.dbids.dz.persistence.ibatis.NSCValidationDAO"
parent="abstractDao" />


</beans>

sql-map-config.xml

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE sqlMapConfig
PUBLIC "-//iBATIS.com//DTD SQL Map Config 2.0//EN"
"http://www.ibatis.com/dtd/sql-map-config-2.dtd">
<!--============================================================================
= DBids iBATIS SQL Maps Configuration =
= =
= @Author: DBids Team, dbidstech@maricom.com =
= @Date: April 12, 2008. =
==========================================================================-->
<sqlMapConfig>
<settings cacheModelsEnabled="false"
statementCachingEnabled="false"
enhancementEnabled="true"
maxSessions="1485"
maxTransactions="594"
maxRequests="5940"
useStatementNamespaces="false"/>
<!--===============================================
SQL Map resources
===============================================-->
<!-- Adding the transactionmanager to eliminate Spring transaction mgmt and depend on EJB CMT -->
<!-- Commented this out to test Spring-iBatis Integration -->
<transactionManager type="EXTERNAL">
<property name="UserTransaction" value="java:comp/env/UserTransaction" />
<dataSource type="JNDI">
<property name="DataSource" value="java:comp/env/jdbc/dbids" />
</dataSource>
</transactionManager>



<sqlMap resource="sql/Model.xml"/>
<sqlMap resource="sql/County.xml"/>
<sqlMap resource="sql/Bid.xml"/>
<sqlMap resource="sql/SubContractor.xml"/>
<sqlMap resource="sql/TopItem.xml"/>
<sqlMap resource="sql/BidItem.xml"/>
<sqlMap resource="sql/User.xml"/>
<sqlMap resource="sql/county_ref.xml"/>
<sqlMap resource="sql/cba_ref.xml"/>
<sqlMap resource="sql/acc_agency_ref.xml"/>
<sqlMap resource="sql/acc_prod_ref.xml"/>
<sqlMap resource="sql/nsc_ref.xml"/>
<sqlMap resource="sql/product_ref.xml"/>
<sqlMap resource="sql/pc_ref.xml"/>
<sqlMap resource="sql/state_ref.xml"/>
<sqlMap resource="sql/org_type_ref.xml"/>
<sqlMap resource="sql/bid_cycle_ref.xml"/>
<sqlMap resource="sql/bidder_type_ref.xml"/>
<sqlMap resource="sql/privilege_ref.xml"/>
<sqlMap resource="sql/role_ref.xml"/>
<sqlMap resource="sql/bidder_status_ref.xml"/>
<sqlMap resource="sql/bid_status_ref.xml"/>
<sqlMap resource="sql/acc_status_ref.xml"/>
<sqlMap resource="sql/prod_customer_ref.xml"/>
<sqlMap resource="sql/prod_revenue_ref.xml"/>
<sqlMap resource="sql/medi_area_ref.xml"/>
<sqlMap resource="sql/medi_customer_ref.xml"/>
<sqlMap resource="sql/medi_revenue_ref.xml"/>

<sqlMap resource="sql/Location.xml"/>
<sqlMap resource="sql/LocationCBAPC.xml"/>
<sqlMap resource="sql/KeyPerson.xml"/>
<sqlMap resource="sql/ContactPerson.xml"/>
<sqlMap resource="sql/Supplier.xml"/>
<sqlMap resource="sql/BidderCBA.xml"/>
<sqlMap resource="sql/BidderCBAPC.xml"/>
<sqlMap resource="sql/Bidder.xml"/>
<sqlMap resource="sql/Accreditation.xml"/>
<sqlMap resource="sql/AccProductClass.xml"/>
<sqlMap resource="sql/status.xml"/>
<sqlMap resource="sql/lock.xml"/>
<sqlMap resource="sql/BidAudit.xml"/>
<sqlMap resource="sql/BidderAudit.xml"/>
<sqlMap resource="sql/NSC.xml"/>


</sqlMapConfig>

Thanks for reading my post. I would really appreciate it if someone could throw some light on this.

Thanks,
Sree

 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"sree"

Please click on the My Profile link above and change your display name to meet the JavaRanch Naming Policy of using your real first and real last names.

Thanks

Mark
 
sreelakshmi sarma
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could somebody please give me a reply. I have a deadline and I am hoping that you guys will throw some light about this.

Thanks a lot.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic