ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniel Kalcevich" <DKalcev...@marketlinx.com>
Subject RE: Database Blocking
Date Mon, 04 Jun 2007 18:41:52 GMT
If you want to get to the SQL Map Client Directly, you could always request it from the Spring
Application Context (aka context.getBean( "sqlMapClient" ) ).  Then you could potentially
bypass the injection into the DAO.  However, I am not sure how you would have to configure
the Transactions around it, because you still need some object to specify the transactions
For our app, we always use a DAO, or if we need specific JDBC calls, we will obtain the Data
Source directly from the Spring Context file, and then get a connection, etc.   But that is
only in very rare cases such as some special blob handling we wanted to do.  Otherwise, we
always go through our Spring DAO's for the transactions and the fact it's easy for us to get
to the Sql Map Client.  Hope this helps.


From: Reese, Rich R. [mailto:Rich.R.Reese@supervalu.com]
Sent: Mon 6/4/2007 11:39 AM
To: user-java@ibatis.apache.org
Subject: RE: Database Blocking

Our Abator generated DAOs are extending the org.springframework.orm.ibatis.support.SqlMapClientDaoSupport
class, but our custom queries do not go through a DAO.  They utilize iBATIS directly through
the SQLMapClient object.  Our architecture is trying to make it so the developer goes to a
DAO for canned Abator generated queries, but then go directly to iBATIS for custom queries.
 Is it not possible or a good idea to go directly to iBATIS through the SqlMapClient?  Should
one always use a DAO?






From: Daniel Kalcevich [mailto:DKalcevich@marketlinx.com] 
Sent: Monday, June 04, 2007 1:26 PM
To: user-java@ibatis.apache.org
Subject: RE: Database Blocking


How are you accessing the code shown in your last post?  We are also using Spring with JBoss,
and it works fine for us.  We pretty much have the same thing you have defined in Spring context.xml
file (for our SQL Map Client), but we inject the SQL Map client into our DAO's by extending
the "org.springframework.orm.ibatis.support.SqlMapClientDaoSupport" class.  Then, our app
context looks like the following:


<bean id="sqlMapClient"


<property name="configLocation" value="WEB-INF/sqlmap-config.xml"/>

<property name="dataSource" ref="dataSource"/>



<bean id="AccountDAO" class="com.app.dao.impl.AccountDAOImpl">

<property name="sqlMapClient">

<ref local="sqlMapClient"/>



what I  am tyring to get at is that you should not have to explicitly build the SqlMapClient.





From: Reese, Rich R. [mailto:Rich.R.Reese@supervalu.com]
Sent: Mon 6/4/2007 10:11 AM
To: user-java@ibatis.apache.org
Subject: RE: Database Blocking

I don't have any transaction calls within my code.  It must be internal calls within iBATIS.
 The line of code it fails on within my code is:


InputStream is = getClass().getClassLoader().getResourceAsStream("SqlMapConfig.xml");    

InputStreamReader reader = new InputStreamReader(is);

SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);


addresses = sqlMap.queryForList("Custom_Queries.selectAddress", params);  //error thrown here






From: Poitras Christian [mailto:Christian.Poitras@ircm.qc.ca] 
Sent: Monday, June 04, 2007 11:20 AM
To: user-java@ibatis.apache.org
Subject: RE: Database Blocking


If you want to use Spring transaction, you should let Spring handle them in all cases.

So it would be better remove all calls like :




iBATIS will automatically use the transaction started by Spring (since Spring seems to be
correctly initiallised based on your file).


These calls may be the root cause of the problem.




From: Reese, Rich R. [mailto:Rich.R.Reese@supervalu.com] 
Sent: Monday, 04 June 2007 11:41
To: user-java@ibatis.apache.org
Subject: RE: Database Blocking

When I remove the transaction info from the SQLMapConfig I get the following error:


Caused by: java.lang.NullPointerException

at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.endTransaction(SqlMapExecutorDelegate.java:782)

at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.endTransaction(SqlMapSessionImpl.java:176)

at com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.endTransaction(SqlMapClientImpl.java:154)

at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.autoEndTransaction(SqlMapExecutorDelegate.java:883)

at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:622)

at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:589)

at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForList(SqlMapSessionImpl.java:118)

at com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.queryForList(SqlMapClientImpl.java:95)

at com.sal.services.retail.storemaint.dao.StoreMapper.findAncillaryInfo(StoreMapper.java:149)


Its like iBATIS doesn't pick up on the spring transaction.





From: Poitras Christian [mailto:Christian.Poitras@ircm.qc.ca] 
Sent: Friday, June 01, 2007 5:16 PM
To: user-java@ibatis.apache.org
Subject: RE: Database Blocking


If you plan to use Spring transaction, you should remove the one in SqlMapConfig.xml.

It is quite probable that they can block each other...





From: Reese, Rich R. [mailto:Rich.R.Reese@supervalu.com] 
Sent: Friday, 01 June 2007 17:34
To: user-java@ibatis.apache.org
Subject: Database Blocking

I am using iBATIS with Spring DAOs.  My application is deployed within a WAR onto a JBoss
4.0.4 server connecting to a MS Sql Server database.  Everything works fine until I try to
have Spring manage the database transaction from one of my business objects.  The problem
I am having is I keep getting database blocks on the table I am inserting or deleting records
from.  I don't have this problem when I keep the transaction management out of the spring-beans.xml
file.  I have attached what I have in the file.  Can someone tell me what I might be missing
or stating incorrectly?


Another confusion I have a datasource defined in my spring-beans.xml file and SqlMapConfig.xml
file?  Why do I need it in both or do I?  Is there a way to tell the SqlMapconfig.xml to use
the transaction defined in the spring-beans.xml?



<?xml version="1.0" encoding="UTF-8"?>


<beans xmlns="http://www.springframework.org/schema/beans"
















  <bean id="dataSource"



    <!-- See jboss-web.xml for definition of jndiNames -->

    <property name="jndiName" value="java:jdbc/storesSqlServerDB"/>




  <bean id="sqlMapClient"


<!--    <property name="configLocation" value="/WEB-INF/classes/SqlMapConfig.xml"/>

    <property name="configLocation" value="classpath:SqlMapConfig.xml"/>


    <property name="dataSource" ref="dataSource"/>



  <!-- Allows developer to put tag at top of method to specify tx needs -->    

  <tx:annotation-driven transaction-manager="txManager"/>


  <!-- Takes care of adding proxy around classes which need transactions.  

   This proxy handles starting the transaction and the commits and rollbacks versus the 

   developer adding this code themselves.




  <bean id="txManager"


    <property name="dataSource" ref="dataSource"/>



  <bean id="StoreMaintService" class="com.sal.services.retail.storemaint.service.impl.StoreMaintServiceImpl"






Rich Reese



View raw message