ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Andrews <peter.andr...@Dartmouth.EDU>
Subject Re: com.ibatis.sqlmap.client.SqlMapException: Duplicate prepared statement found. This is likely a bug.
Date Wed, 15 Nov 2006 15:56:00 GMT
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
I am sorry but I don't have the time to distill everything to a nice
example. My guess is that it easy to replicate by following my
essential (possibly poor) technique which is that the setter for one of
my resultClass properties makes another call to the db via iBATIS (see
the setGeneKey method in GeneExperimentResult.java).<br>
<br>
As I read more about iBATIS, I realize the more conventional way to
accomplish what I want is to use a resultMap with Complex Properties
such that a returned foreignKey to another class retrieves that class.
I did not do so because I think it is more complicated, particularly
given that I am not using any resultMaps since my column names and bean
names match exactly.<br>
<br>
Brandon Goodin wrote:
<blockquote
 cite="mid2fe5ef5b0611141002n59ffbf78o487a42663c3fdc93@mail.gmail.com"
 type="cite">Please post your code involved in producing this. Post
sqlmap config, dao java code, and bean java code.<br>
  <br>
Brandon<br>
  <br>
  <div><span class="gmail_quote">On 11/14/06, <b
 class="gmail_sendername">Peter Andrews</b> &lt;<a
 href="mailto:peter.andrews@dartmouth.edu">
peter.andrews@dartmouth.edu</a>&gt; wrote:</span>
  <blockquote class="gmail_quote"
 style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left:
1ex;">I
am sorry if this has been discussed previously -- the mail archives
    <br>
seem to be currently unavailable (get network connection error).<br>
    <br>
I am getting an error. The error message is different between 2.2.0 and<br>
the subversion latest. The error in the subject line is from the<br>
subversion code. In the 2.2.0 I get:<br>
    <br>
com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Result consisted of<br>
more than one row<br>
    <br>
When the message says 'This is likely a bug' does it mean a bug in<br>
iBATIS or a bug in my code? I think it means iBATIS.
    <br>
    <br>
At the bottom of this email is a partial stack trace (the full trace<br>
goes on for a very long time repeating itself and ends with&nbsp;&nbsp;'...30
more').<br>
    <br>
I think the issue is that one of my calls into iBATIS can cause
    <br>
additional calls to occur before the first one ends. This is because<br>
some of my setter functions also make calls to the db.<br>
    <br>
The iBATIS code that is throwing the exception is in SessionScope.java:<br>
&nbsp;&nbsp;public void putPreparedStatement(String sql, PreparedStatement ps) {
    <br>
&nbsp;&nbsp;&nbsp;&nbsp;if (!isInBatch()) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (hasPreparedStatementFor(sql))<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;throw new
SqlMapException("Duplicate prepared statement found.<br>
This is likely a bug.");<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;preparedStatements.put(sql, ps);
    <br>
&nbsp;&nbsp;&nbsp;&nbsp;}<br>
&nbsp;&nbsp;}<br>
    <br>
Changing the iBATIS code to:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (!hasPreparedStatementFor(sql))<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;preparedStatements.put(sql,
ps);<br>
    <br>
appears to fix the problem. I am an iBATIS novice user so is likely not<br>
a correct fix (if the problem is even iBATIS').<br>
    <br>
    <br>
Here is the stack trace:<br>
run-single:<br>
DEBUG: iBATIS SqlMap for db 'GeneDataset' initialized<br>
DEBUG: queryForObject 'getResearcherByUsername' passing: PeterVermont
    <br>
DEBUG: queryForObject 'getResearcherByUsername' returning:<br>
org.epistasis.db.geneExperiment.Researcher[id=1]<br>
DEBUG: queryForList 'getGeneExperimentResultsByDatasetExperimentId'<br>
passing: 1&nbsp;&nbsp; &lt;==*********************NOTE: Still in process when
when
    <br>
following calls start<br>
DEBUG: queryForObject 'getGeneKeyById' passing: 1<br>
DEBUG: queryForObject 'getGeneKeyById' returning:<br>
org.epistasis.db.geneExperiment.GeneKey[id=1]<br>
DEBUG: queryForObject 'getGeneKeyById' passing:
    <br>
2<br>
&lt;==*********************NOTE: second call to getGeneKeyById since<br>
    <br>
    <br>
    <br>
'getGeneExperimentResultsByDatasetExperimentId' started<br>
com.ibatis.common.jdbc.exception.NestedSQLException:<br>
--- The error occurred in org/epistasis/db/geneDataset/GeneDataset.xml.
    <br>
--- The error occurred while executing query.<br>
--- Check the&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CALL getGeneKeyById(?)&nbsp;&nbsp;
.<br>
--- Check the SQL Statement (preparation failed).<br>
--- Cause: com.ibatis.sqlmap.client.SqlMapException: Duplicate prepared
    <br>
statement found.&nbsp;&nbsp;This is likely a bug.<br>
Caused by: com.ibatis.sqlmap.client.SqlMapException: Duplicate prepared<br>
statement found.&nbsp;&nbsp;This is likely a bug.<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at<br>
com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback
(GeneralStatement.java:188)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at<br>
com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryForObject(GeneralStatement.java:104)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at<br>
com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject
(SqlMapExecutorDelegate.java:566)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at<br>
com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:541)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at<br>
com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForObject
(SqlMapSessionImpl.java:106)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at<br>
com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.queryForObject(SqlMapClientImpl.java:83)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at<br>
org.epistasis.db.SqlMapClientWrapper.queryForObject(SqlMapClientWrapper.java
:21)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at<br>
org.epistasis.db.geneDataset.GeneDatasetDbAccess.getGeneKeyById(GeneDatasetDbAccess.java:94)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at<br>
org.epistasis.db.geneDataset.GeneKey.getGeneKeyById(GeneKey.java:49)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at<br>
org.epistasis.db.geneDataset.GeneExperimentResult.setGeneKeyId
(GeneExperimentResult.java:110)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at<br>
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at<br>
sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:25)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at java.lang.reflect.Method.invoke(Method.java:585)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at<br>
com.ibatis.sqlmap.engine.accessplan.PropertyAccessPlan.setProperties(PropertyAccessPlan.java:46)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at
    <br>
com.ibatis.sqlmap.engine.exchange.JavaBeanDataExchange.setData(JavaBeanDataExchange.java:115)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at<br>
com.ibatis.sqlmap.engine.mapping.result.BasicResultMap.setResultObjectValues(BasicResultMap.java:373)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at
    <br>
com.ibatis.sqlmap.engine.mapping.statement.RowHandlerCallback.handleResultObject(RowHandlerCallback.java:64)<br>
ERROR: Caught an exception<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at<br>
com.ibatis.sqlmap.engine.execution.SqlExecutor.handleResults(
SqlExecutor.java:377)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at<br>
com.ibatis.sqlmap.engine.execution.SqlExecutor.handleMultipleResults(SqlExecutor.java:296)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at<br>
com.ibatis.sqlmap.engine.execution.SqlExecutor.executeQuery(SqlExecutor.java
:187)<br>
com.ibatis.common.jdbc.exception.RuntimeSQLException:<br>
com.ibatis.common.jdbc.exception.NestedSQLException:<br>
--- The error occurred in org/epistasis/db/geneDataset/GeneDataset.xml.<br>
--- The error occurred while applying a result map.
    <br>
--- Check the
getGeneExperimentResultsByDatasetExperimentId-AutoResultMap.<br>
--- The error happened while setting a property on the result object.<br>
--- Cause: java.lang.RuntimeException: Error setting property<br>
'setGeneKeyId' of
    <br>
'org.epistasis.db.geneExperiment.GeneExperimentResult[id=2]'.&nbsp;&nbsp;Cause:<br>
com.ibatis.common.jdbc.exception.RuntimeSQLException:<br>
com.ibatis.common.jdbc.exception.NestedSQLException:<br>
--- The error occurred in org/epistasis/db/geneDataset/GeneDataset.xml.
    <br>
--- The error occurred while executing query.<br>
--- Check the&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CALL getGeneKeyById(?)&nbsp;&nbsp;
.<br>
--- Check the SQL Statement (preparation failed).<br>
--- Cause: com.ibatis.sqlmap.client.SqlMapException: Duplicate prepared
    <br>
statement found.&nbsp;&nbsp;This is likely a bug.<br>
Caused by: com.ibatis.sqlmap.client.SqlMapException: Duplicate prepared<br>
statement found.&nbsp;&nbsp;This is likely a bug.<br>
Caused by: java.lang.RuntimeException: Error setting property
    <br>
'setGeneKeyId' of<br>
'org.epistasis.db.geneExperiment.GeneExperimentResult[id=2]'.&nbsp;&nbsp;Cause:<br>
com.ibatis.common.jdbc.exception.RuntimeSQLException:<br>
com.ibatis.common.jdbc.exception.NestedSQLException:<br>
--- The error occurred in org/epistasis/db/geneDataset/GeneDataset.xml.
    <br>
--- The error occurred while executing query.<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at<br>
com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.sqlExecuteQuery(GeneralStatement.java:205)<br>
--- Check the&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CALL getGeneKeyById(?)&nbsp;&nbsp;
.<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at<br>
com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback(GeneralStatement.java:173)<br>
--- Check the SQL Statement (preparation failed).<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at<br>
com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryForList
(GeneralStatement.java:123)<br>
--- Cause: com.ibatis.sqlmap.client.SqlMapException: Duplicate prepared<br>
statement found.&nbsp;&nbsp;This is likely a bug.<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at<br>
com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList
(SqlMapExecutorDelegate.java:615)<br>
Caused by: com.ibatis.sqlmap.client.SqlMapException: Duplicate prepared<br>
statement found.&nbsp;&nbsp;This is likely a bug.<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at<br>
com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList
(SqlMapExecutorDelegate.java:589)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at<br>
com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForList(SqlMapSessionImpl.java:118)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at<br>
org.epistasis.db.SqlMapClientWrapper.queryForList(SqlMapClientWrapper.java
:50)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at<br>
com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.queryForList(SqlMapClientImpl.java:95)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at<br>
org.epistasis.db.geneDataset.GeneDatasetDbAccess.getGeneExperimentResultsByDatasetExperimentId(GeneDatasetDbAccess.java
:90)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at<br>
org.epistasis.db.SqlMapClientWrapper.queryForList(SqlMapClientWrapper.java:45)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at<br>
org.epistasis.db.geneDataset.GeneDatasetDbAccess.main(GeneDatasetDbAccess.java:167)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at<br>
org.epistasis.db.geneDataset.GeneDatasetDbAccess.getGeneExperimentResultsByDatasetExperimentId
(GeneDatasetDbAccess.java:90)<br>
Caused by: com.ibatis.common.jdbc.exception.NestedSQLException:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at<br>
org.epistasis.db.geneDataset.GeneDatasetDbAccess.main(GeneDatasetDbAccess.java:167)<br>
--- The error occurred in org/epistasis/db/geneDataset/GeneDataset.xml.
    <br>
Caused by: com.ibatis.sqlmap.client.SqlMapException: Duplicate prepared<br>
statement found.&nbsp;&nbsp;This is likely a bug.<br>
--- The error occurred while applying a result map.<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at<br>
com.ibatis.sqlmap.engine.scope.SessionScope.putPreparedStatement
(SessionScope.java:247)<br>
--- Check the
getGeneExperimentResultsByDatasetExperimentId-AutoResultMap.<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at<br>
com.ibatis.sqlmap.engine.execution.SqlExecutor.prepareStatement(SqlExecutor.java:488)<br>
--- The error happened while setting a property on the result object.
    <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at<br>
com.ibatis.sqlmap.engine.execution.SqlExecutor.executeQuery(SqlExecutor.java:173)<br>
--- Cause: java.lang.RuntimeException: Error setting property<br>
'setGeneKeyId' of<br>
'org.epistasis.db.geneExperiment.GeneExperimentResult
[id=2]'.&nbsp;&nbsp;Cause:<br>
com.ibatis.common.jdbc.exception.RuntimeSQLException:<br>
com.ibatis.common.jdbc.exception.NestedSQLException:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at<br>
com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.sqlExecuteQuery
(GeneralStatement.java:205)<br>
--- The error occurred in org/epistasis/db/geneDataset/GeneDataset.xml.<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at<br>
com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback(GeneralStatement.java
:173)<br>
--- The error occurred while executing query.<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;... 30 more<br>
    <br>
--<br>
Peter Andrews<br>
Software Engineer<br>
Dartmouth Medical School<br>
Computational Genetics<br>
Rubin 707<br>
(603) 653-3598<br>
    <a href="mailto:Peter.Andrews@dartmouth.edu">Peter.Andrews@dartmouth.edu</a><br>
    <br>
  </blockquote>
  </div>
  <br>
</blockquote>
<br>
<pre class="moz-signature" cols="72">-- 
Peter Andrews
Software Engineer
Dartmouth Medical School
Computational Genetics
Rubin 707
(603) 653-3598
<a class="moz-txt-link-abbreviated" href="mailto:Peter.Andrews@dartmouth.edu">Peter.Andrews@dartmouth.edu</a>
</pre>
</body>
</html>

Mime
View raw message