ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gwyn Evans <gwyn.ev...@gmail.com>
Subject Re: Database Blocking
Date Mon, 04 Jun 2007 19:27:55 GMT
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><title></title>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-15">
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
body {
  margin: 5px 5px 5px 5px;
  background-color: #ffffff;
}
/* ========== Text Styles ========== */
hr { color: #000000}
body, table /* Normal text */
{
 font-size: 9pt;
 font-family: 'Verdana';
 font-style: normal;
 font-weight: normal;
 color: #000000;
 text-decoration: none;
}
span.rvts1 /* Heading */
{
 font-size: 10pt;
 font-family: 'Arial';
 font-weight: bold;
 color: #0000ff;
}
span.rvts2 /* Subheading */
{
 font-size: 10pt;
 font-family: 'Arial';
 font-weight: bold;
 color: #000080;
}
span.rvts3 /* Keywords */
{
 font-size: 10pt;
 font-family: 'Arial';
 font-style: italic;
 color: #800000;
}
a.rvts4, span.rvts4 /* Jump 1 */
{
 font-size: 10pt;
 font-family: 'Arial';
 color: #008000;
 text-decoration: underline;
}
a.rvts5, span.rvts5 /* Jump 2 */
{
 font-size: 10pt;
 font-family: 'Arial';
 color: #008000;
 text-decoration: underline;
}
a.rvts6, span.rvts6
{
 color: #0000ff;
 text-decoration: underline;
}
span.rvts7
{
 font-size: 11pt;
 font-family: 'tahoma';
 font-weight: bold;
 color: #ffffff;
 background-color: #0000ff;
}
span.rvts8
{
 font-family: 'arial';
 color: #000080;
}
span.rvts9
{
 font-family: 'courier new';
}
span.rvts10
{
 font-family: 'tahoma';
 font-weight: bold;
}
span.rvts11
{
 font-family: 'tahoma';
}
span.rvts12
{
 font-size: 12pt;
 font-family: 'times new roman';
}
span.rvts13
{
 font-family: 'arial';
 color: #0000ff;
}
span.rvts14
{
 font-family: 'courier new';
 color: #2a00ff;
}
span.rvts15
{
 font-family: 'courier new';
 background-color: #c0c0c0;
}
span.rvts16
{
 font-family: 'courier new';
 font-weight: bold;
 color: #7f0055;
}
span.rvts17
{
 font-family: 'courier new';
 font-style: italic;
}
span.rvts18
{
 font-family: 'arial';
}
a.rvts19, span.rvts19
{
 color: #0000ff;
 text-decoration: underline;
}
/* ========== Para Styles ========== */
p,ul,ol /* Paragraph Style */
{
 text-align: left;
 text-indent: 0px;
 padding: 0px 0px 0px 0px;
 margin: 0px 0px 0px 0px;
}
.rvps1 /* Centered */
{
 text-align: center;
}
--></style>
</head>
<body>

<p>On Monday, June 4, 2007, 7:42:49 PM, Rich &lt;<a class=rvts6 href="mailto:Rich.R.Reese@supervalu.com">Rich.R.Reese@supervalu.com</a>&gt;
wrote:</p>
<p><br></p>
<p>Maybe see if the examples at&nbsp;<a class=rvts19 href="http://cwiki.apache.org/WICKET/ibatis.html">http://cwiki.apache.org/WICKET/ibatis.html</a>&nbsp;helps
you any?</p>
<p><br></p>
<p>/Gwyn</p>
<p><br></p>
<div><table border=0 cellpadding=1 cellspacing=2>
<tr valign=top>
<td width=12 style="background-color: #0000ff;">
<p><span class=rvts7>&gt;</span></p>
</td>
<td width=652 style="background-color: #ffffff;">
<p><span class=rvts8>How do you initialize the&nbsp;</span><span
class=rvts9>sqlMap variable or make a call to the queryForList method if you don&#8217;t
use the SqlMapClientBuilder?</span></p>
<p><span class=rvts8>&nbsp;</span></p>
<hr noshade size=2>
<p><span class=rvts10>From:</span><span class=rvts11>&nbsp;Poitras
Christian [mailto:Christian.Poitras@ircm.qc.ca]&nbsp;</span></p>
<p><span class=rvts10>Sent:</span><span class=rvts11>&nbsp;Monday,
June 04, 2007 1:33 PM</span></p>
<p><span class=rvts10>To:</span><span class=rvts11>&nbsp;user-java@ibatis.apache.org</span></p>
<p><span class=rvts10>Subject:</span><span class=rvts11>&nbsp;RE:
Database Blocking</span></p>
<p><span class=rvts12>&nbsp;</span></p>
<p><span class=rvts13>I doudt these code lines should be there.</span></p>
<p><span class=rvts13>iBATIS is configured by Spring with your configuration.</span></p>
<p><span class=rvts12>&nbsp;</span></p>
<p><span class=rvts13>&nbsp; &lt;bean id="sqlMapClient"</span></p>
<p><span class=rvts13>&nbsp; &nbsp; class="org.springframework.orm.ibatis.SqlMapClientFactoryBean"&gt;</span></p>
<p><span class=rvts13>&lt;!-- &nbsp; &nbsp;&lt;property name="configLocation"
value="/WEB-INF/classes/SqlMapConfig.xml"/&gt; --&gt;</span></p>
<p><span class=rvts13>This line -&gt; &nbsp; &nbsp;&lt;property
name="configLocation" value="classpath:SqlMapConfig.xml"/&gt;</span></p>
<p><span class=rvts13>&nbsp;</span></p>
<p><span class=rvts13>&nbsp; &nbsp; &lt;property name="dataSource"
ref="dataSource"/&gt;</span></p>
<p><span class=rvts13>&nbsp; &lt;/bean&gt;</span></p>
<p><span class=rvts12>&nbsp;</span></p>
<p><span class=rvts13>Is there a reason you need to use&nbsp;</span><span
class=rvts9>SqlMapClientBuilder?</span></p>
<p><span class=rvts12>&nbsp;</span></p>
<p><span class=rvts13>In my code, I only keep</span></p>
<p><span class=rvts9>addresses = sqlMap.queryForList(</span><span class=rvts14>"Custom_Queries.selectAddress"</span><span
class=rvts9>, params);</span><span class=rvts12>&nbsp;</span></p>
<p><span class=rvts12>&nbsp;</span></p>
<p><span class=rvts13>Try this!</span></p>
<p><span class=rvts13>Christian</span></p>
<p><span class=rvts12>&nbsp;</span></p>
<hr noshade size=2>
<p><span class=rvts10>From:</span><span class=rvts11>&nbsp;Reese,
Rich R. [mailto:Rich.R.Reese@supervalu.com]&nbsp;</span></p>
<p><span class=rvts10>Sent:</span><span class=rvts11>&nbsp;Monday,
04 June 2007 13:12</span></p>
<p><span class=rvts10>To:</span><span class=rvts11>&nbsp;user-java@ibatis.apache.org</span></p>
<p><span class=rvts10>Subject:</span><span class=rvts11>&nbsp;RE:
Database Blocking</span></p>
<p><span class=rvts8>I don&#8217;t have any transaction calls within my code.
&nbsp;It must be internal calls within iBATIS. &nbsp;The line of code it fails on
within my code is:</span></p>
<p><span class=rvts8>&nbsp;</span></p>
<p><span class=rvts9>InputStream is = getClass().getClassLoader().getResourceAsStream(</span><span
class=rvts14>"SqlMapConfig.xml"</span><span class=rvts9>); &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span></p>
<p><span class=rvts15>InputStreamReader</span><span class=rvts9>&nbsp;reader
=&nbsp;</span><span class=rvts16>new</span><span class=rvts9>&nbsp;InputStreamReader(is);</span></p>
<p><span class=rvts9>SqlMapClient sqlMap = SqlMapClientBuilder.</span><span
class=rvts17>buildSqlMapClient</span><span class=rvts9>(reader);</span></p>
<p><span class=rvts8>&nbsp;</span></p>
<p><span class=rvts9>addresses = sqlMap.queryForList(</span><span class=rvts14>"Custom_Queries.selectAddress"</span><span
class=rvts9>, params); &nbsp;//error thrown here</span></p>
<p><span class=rvts9>&#8230;</span></p>
<p><span class=rvts9>&#8230;</span></p>
<p><span class=rvts8>&nbsp;</span></p>
<p><span class=rvts8>&nbsp;</span></p>
<hr noshade size=2>
<p><span class=rvts10>From:</span><span class=rvts11>&nbsp;Poitras
Christian [mailto:Christian.Poitras@ircm.qc.ca]&nbsp;</span></p>
<p><span class=rvts10>Sent:</span><span class=rvts11>&nbsp;Monday,
June 04, 2007 11:20 AM</span></p>
<p><span class=rvts10>To:</span><span class=rvts11>&nbsp;user-java@ibatis.apache.org</span></p>
<p><span class=rvts10>Subject:</span><span class=rvts11>&nbsp;RE:
Database Blocking</span></p>
<p><span class=rvts12>&nbsp;</span></p>
<p><span class=rvts13>If you want to use Spring transaction, you should let Spring
handle them in all cases.</span></p>
<p><span class=rvts13>So it would be better remove all calls like :</span></p>
<p><span class=rvts13>sqlMap.startTransaction();</span></p>
<p><span class=rvts13>sqlMap.commitTransaction();</span></p>
<p><span class=rvts13>sqlMap.endTransaction();</span></p>
<p><span class=rvts13>iBATIS will automatically use the transaction started by
Spring (since Spring seems to be correctly initiallised based on your file).</span></p>
<p><span class=rvts12>&nbsp;</span></p>
<p><span class=rvts13>These calls may be the root cause of the problem.</span></p>
<p><span class=rvts12>&nbsp;</span></p>
<p><span class=rvts12>&nbsp;</span></p>
<hr noshade size=2>
<p><span class=rvts10>From:</span><span class=rvts11>&nbsp;Reese,
Rich R. [mailto:Rich.R.Reese@supervalu.com]&nbsp;</span></p>
<p><span class=rvts10>Sent:</span><span class=rvts11>&nbsp;Monday,
04 June 2007 11:41</span></p>
<p><span class=rvts10>To:</span><span class=rvts11>&nbsp;user-java@ibatis.apache.org</span></p>
<p><span class=rvts10>Subject:</span><span class=rvts11>&nbsp;RE:
Database Blocking</span></p>
<p><span class=rvts8>When I remove the transaction info from the SQLMapConfig
I get the following error:</span></p>
<p><span class=rvts8>&nbsp;</span></p>
<p><span class=rvts8>Caused by: java.lang.NullPointerException</span></p>
<p><span class=rvts8>at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.endTransaction(SqlMapExecutorDelegate.java:782)</span></p>
<p><span class=rvts8>at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.endTransaction(SqlMapSessionImpl.java:176)</span></p>
<p><span class=rvts8>at com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.endTransaction(SqlMapClientImpl.java:154)</span></p>
<p><span class=rvts8>at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.autoEndTransaction(SqlMapExecutorDelegate.java:883)</span></p>
<p><span class=rvts8>at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:622)</span></p>
<p><span class=rvts8>at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:589)</span></p>
<p><span class=rvts8>at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForList(SqlMapSessionImpl.java:118)</span></p>
<p><span class=rvts8>at com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.queryForList(SqlMapClientImpl.java:95)</span></p>
<p><span class=rvts8>at com.sal.services.retail.storemaint.dao.StoreMapper.findAncillaryInfo(StoreMapper.java:149)</span></p>
<p><span class=rvts8>&nbsp;</span></p>
<p><span class=rvts8>Its like iBATIS doesn&#8217;t pick up on the spring transaction.</span></p>
<p><span class=rvts8>&nbsp;</span></p>
<p><span class=rvts8>Thoughts?</span></p>
<p><span class=rvts8>&nbsp;</span></p>
<hr noshade size=2>
<p><span class=rvts10>From:</span><span class=rvts11>&nbsp;Poitras
Christian [mailto:Christian.Poitras@ircm.qc.ca]&nbsp;</span></p>
<p><span class=rvts10>Sent:</span><span class=rvts11>&nbsp;Friday,
June 01, 2007 5:16 PM</span></p>
<p><span class=rvts10>To:</span><span class=rvts11>&nbsp;user-java@ibatis.apache.org</span></p>
<p><span class=rvts10>Subject:</span><span class=rvts11>&nbsp;RE:
Database Blocking</span></p>
<p><span class=rvts12>&nbsp;</span></p>
<p><span class=rvts13>If you plan to use Spring transaction, you should remove
the one in SqlMapConfig.xml.</span></p>
<p><span class=rvts13>It is quite probable that they can block each other...</span></p>
<p><span class=rvts12>&nbsp;</span></p>
<p><span class=rvts13>Christian</span></p>
<p><span class=rvts12>&nbsp;</span></p>
<hr noshade size=2>
<p><span class=rvts10>From:</span><span class=rvts11>&nbsp;Reese,
Rich R. [mailto:Rich.R.Reese@supervalu.com]&nbsp;</span></p>
<p><span class=rvts10>Sent:</span><span class=rvts11>&nbsp;Friday,
01 June 2007 17:34</span></p>
<p><span class=rvts10>To:</span><span class=rvts11>&nbsp;user-java@ibatis.apache.org</span></p>
<p><span class=rvts10>Subject:</span><span class=rvts11>&nbsp;Database
Blocking</span></p>
<p><span class=rvts18>I am using iBATIS with Spring DAOs. &nbsp;My application
is deployed within a WAR onto a JBoss 4.0.4 server connecting to a MS Sql Server database.
&nbsp;Everything works fine until I try to have Spring manage the database transaction
from one of my business objects. &nbsp;The problem I am having is I keep getting database
blocks on the table I am inserting or deleting records from. &nbsp;I don&#8217;t have
this problem when I keep the transaction management out of the spring-beans.xml file. &nbsp;I
have attached what I have in the file. &nbsp;Can someone tell me what I might be missing
or stating incorrectly?</span></p>
<p><span class=rvts18>&nbsp;</span></p>
<p><span class=rvts18>Another confusion I have a datasource defined in my spring-beans.xml
file and SqlMapConfig.xml file? &nbsp;Why do I need it in both or do I? &nbsp;Is there
a way to tell the SqlMapconfig.xml to use the transaction defined in the spring-beans.xml?</span></p>
<p><span class=rvts18>&nbsp;</span></p>
<p><span class=rvts18>&nbsp;</span></p>
<p><span class=rvts18>&lt;?xml version="1.0" encoding="UTF-8"?&gt;</span></p>
<p><span class=rvts18>&nbsp;</span></p>
<p><span class=rvts18>&lt;beans xmlns="http://www.springframework.org/schema/beans"</span></p>
<p><span class=rvts18>&nbsp; xmlns:aop="http://www.springframework.org/schema/aop"</span></p>
<p><span class=rvts18>&nbsp; xmlns:jee="http://www.springframework.org/schema/jee"</span></p>
<p><span class=rvts18>&nbsp; xmlns:tx="http://www.springframework.org/schema/tx"</span></p>
<p><span class=rvts18>&nbsp; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"</span></p>
<p><span class=rvts18>&nbsp; xsi:schemaLocation="</span></p>
<p><span class=rvts18>&nbsp; &nbsp; http://www.springframework.org/schema/aop</span></p>
<p><span class=rvts18>&nbsp; &nbsp; http://www.springframework.org/schema/aop/spring-aop-2.0.xsd</span></p>
<p><span class=rvts18>&nbsp; &nbsp; http://www.springframework.org/schema/beans</span></p>
<p><span class=rvts18>&nbsp; &nbsp; http://www.springframework.org/schema/beans/spring-beans-2.0.xsd</span></p>
<p><span class=rvts18>&nbsp; &nbsp; http://www.springframework.org/schema/jee</span></p>
<p><span class=rvts18>&nbsp; &nbsp; http://www.springframework.org/schema/jee/spring-jee-2.0.xsd</span></p>
<p><span class=rvts18>&nbsp; &nbsp; http://www.springframework.org/schema/tx</span></p>
<p><span class=rvts18>&nbsp; &nbsp; http://www.springframework.org/schema/tx/spring-tx-2.0.xsd"</span></p>
<p><span class=rvts18>&gt;&nbsp;</span></p>
<p><span class=rvts18>&nbsp;</span></p>
<p><span class=rvts18>&nbsp; &lt;bean id="dataSource"</span></p>
<p><span class=rvts18>&nbsp; &nbsp; class="org.springframework.jndi.JndiObjectFactoryBean"&gt;</span></p>
<p><span class=rvts18>&nbsp; &nbsp;&nbsp;</span></p>
<p><span class=rvts18>&nbsp; &nbsp; &lt;!-- See jboss-web.xml for
definition of jndiNames --&gt;</span></p>
<p><span class=rvts18>&nbsp; &nbsp; &lt;property name="jndiName" value="java:jdbc/storesSqlServerDB"/&gt;</span></p>
<p><span class=rvts18>&nbsp; &nbsp;&nbsp;</span></p>
<p><span class=rvts18>&nbsp; &lt;/bean&gt;</span></p>
<p><span class=rvts18>&nbsp;</span></p>
<p><span class=rvts18>&nbsp; &lt;bean id="sqlMapClient"</span></p>
<p><span class=rvts18>&nbsp; &nbsp; class="org.springframework.orm.ibatis.SqlMapClientFactoryBean"&gt;</span></p>
<p><span class=rvts18>&lt;!-- &nbsp; &nbsp;&lt;property name="configLocation"
value="/WEB-INF/classes/SqlMapConfig.xml"/&gt; --&gt;</span></p>
<p><span class=rvts18>&nbsp; &nbsp; &lt;property name="configLocation"
value="classpath:SqlMapConfig.xml"/&gt;</span></p>
<p><span class=rvts18>&nbsp;</span></p>
<p><span class=rvts18>&nbsp; &nbsp; &lt;property name="dataSource"
ref="dataSource"/&gt;</span></p>
<p><span class=rvts18>&nbsp; &lt;/bean&gt;</span></p>
<p><span class=rvts18>&nbsp;</span></p>
<p><span class=rvts18>&nbsp; &lt;!-- Allows developer to put tag at top
of method to specify tx needs --&gt; &nbsp; &nbsp;</span></p>
<p><span class=rvts18>&nbsp; &lt;tx:annotation-driven transaction-manager="txManager"/&gt;</span></p>
<p><span class=rvts18>&nbsp;</span></p>
<p><span class=rvts18>&nbsp; &lt;!-- Takes care of adding proxy around
classes which need transactions. &nbsp;</span></p>
<p><span class=rvts18>&nbsp; &nbsp;This proxy handles starting the transaction
and the commits and rollbacks versus the&nbsp;</span></p>
<p><span class=rvts18>&nbsp; &nbsp;developer adding this code themselves.</span></p>
<p><span class=rvts18>&nbsp; &nbsp;--&gt;</span></p>
<p><span class=rvts18>&nbsp; &lt;aop:aspectj-autoproxy/&gt;</span></p>
<p><span class=rvts18>&nbsp;</span></p>
<p><span class=rvts18>&nbsp; &lt;bean id="txManager"</span></p>
<p><span class=rvts18>&nbsp; &nbsp; class="org.springframework.jdbc.datasource.DataSourceTransactionManager"&gt;</span></p>
<p><span class=rvts18>&nbsp; &nbsp; &lt;property name="dataSource"
ref="dataSource"/&gt;</span></p>
<p><span class=rvts18>&nbsp; &lt;/bean&gt;</span></p>
<p><span class=rvts18>&nbsp;&nbsp;</span></p>
<p><span class=rvts18>&nbsp; &lt;bean id="StoreMaintService" class="com.sal.services.retail.storemaint.service.impl.StoreMaintServiceImpl"
/&gt;</span></p>
<p><span class=rvts18>&nbsp;</span></p>
<p><span class=rvts18>&lt;/beans&gt;</span></p>
<p><span class=rvts18>&nbsp;</span></p>
<p><span class=rvts18>Thanks,</span></p>
<p><span class=rvts18>&nbsp;</span></p>
<p><span class=rvts18>Rich Reese</span></p>
<p><span class=rvts12>&nbsp;</span></p>
<p><span class=rvts12>&nbsp;</span></p>
</td>
</tr>
</table>
</div>
<p><br></p>
<p><br></p>
<p><br></p>
<p><br></p>
<p>/Gwyn</p>

</body></html>


Mime
View raw message