Giter VIP home page Giter VIP logo

Comments (8)

GoogleCodeExporter avatar GoogleCodeExporter commented on September 26, 2024
I have the same problem. It happens when I : 
- execute an update
- commit
- execute the SAME update,

The problem is in ReuseExecutor.hasStatementFor(...) :

This method does a "statementMap.get(sql).getConnection().isClosed()", but
"statementMap.get(sql).getConnection()" returns null since doFlushStatements 
(in the
same class) was called during the last commit.
doFlushStatements invokes closeStatement() on all statements cached in 
statementMap,
and it seems this set their connection to null (maybe it depends on JdbcDrivers 
? I
use mysql-connector-java-5.1.12-bin.jar).

I suggest adding "statementMap.clear();" in doFlushStatements after having 
closed all
the statements it contains.

What do you think about this ?
Thank you.

Luc Vidal

Original comment by [email protected] on 4 Jun 2010 at 9:20

from mybatis.

GoogleCodeExporter avatar GoogleCodeExporter commented on September 26, 2024

Original comment by [email protected] on 24 Sep 2010 at 12:18

  • Changed state: Accepted

from mybatis.

GoogleCodeExporter avatar GoogleCodeExporter commented on September 26, 2024
I am unable to reproduce the error even with the 
mysql-connector-java-5.1.12-bin.jar driver. I seems that it may depends on your 
configuration. I use JNDI with JDBC transactions.

Still, adding "statementMap.clear();" in ReuseExecutor.doFlushStatements() 
makes sense so I've applied the change in mybatis trunk. Can one of you two 
checkout the code and check if it works?

Original comment by [email protected] on 24 Sep 2010 at 2:07

  • Added labels: Component-SqlMaps

from mybatis.

GoogleCodeExporter avatar GoogleCodeExporter commented on September 26, 2024

Original comment by [email protected] on 24 Sep 2010 at 2:07

  • Changed state: Started

from mybatis.

GoogleCodeExporter avatar GoogleCodeExporter commented on September 26, 2024
To test, I did a simple (using reuseExecutor) :

openSession();
System.out.println("select 1");
selectXXX();
System.out.println("commit");
commit();
System.out.println("select 2");
selectXXX();
System.out.println("commit");
commit();

With the old version, I get : 
select 1
commit
select 2
com.sfr.bt.sh.dmc.callengine.dao.DatabaseException: 
org.apache.ibatis.exceptions.PersistenceException: 
### Error querying database.  Cause: java.lang.NullPointerException
### The error may exist in 
com/sfr/bt/sh/dmc/callengine/dao/engine/ImportMapper.xml
### The error may involve 
com.sfr.bt.sh.dmc.callengine.dao.engine.ImportMapper.selectImport
### The error occurred while executing a query
### Cause: java.lang.NullPointerException
        at com.sfr.bt.sh.dmc.callengine.dao.engine.EngineDao.selectImport(EngineDao.java:129)
        at com.sfr.bt.sh.dmc.callengine.Main.main(Main.java:33)
Caused by: org.apache.ibatis.exceptions.PersistenceException: 
### Error querying database.  Cause: java.lang.NullPointerException
### The error may exist in 
com/sfr/bt/sh/dmc/callengine/dao/engine/ImportMapper.xml
### The error may involve 
com.sfr.bt.sh.dmc.callengine.dao.engine.ImportMapper.selectImport
### The error occurred while executing a query
### Cause: java.lang.NullPointerException
        at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:8)
        at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:61)
        at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:53)
        at org.apache.ibatis.binding.MapperMethod.executeForList(MapperMethod.java:82)
        at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:63)
        at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:35)
        at $Proxy1.selectImport(Unknown Source)
        at com.sfr.bt.sh.dmc.callengine.dao.engine.EngineDao.selectImport(EngineDao.java:127)
        ... 1 more
Caused by: java.lang.NullPointerException
        at org.apache.ibatis.executor.ReuseExecutor.hasStatementFor(ReuseExecutor.java:68)
        at org.apache.ibatis.executor.ReuseExecutor.prepareStatement(ReuseExecutor.java:55)
        at org.apache.ibatis.executor.ReuseExecutor.doQuery(ReuseExecutor.java:38)
        at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:94)
        at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:72)
        at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:59)
        ... 7 more


whereas with the svn version :
select 1
commit
select 2
commit
update 1
commit
update 2
commit


So the change works.

Luc Vidal

Original comment by [email protected] on 28 Sep 2010 at 1:26

from mybatis.

GoogleCodeExporter avatar GoogleCodeExporter commented on September 26, 2024

Original comment by [email protected] on 8 Oct 2010 at 12:23

  • Changed state: Fixed

from mybatis.

GoogleCodeExporter avatar GoogleCodeExporter commented on September 26, 2024

Original comment by [email protected] on 8 Oct 2010 at 12:24

  • Added labels: Target-Release3.0.3

from mybatis.

GoogleCodeExporter avatar GoogleCodeExporter commented on September 26, 2024

Original comment by eduardo.macarron on 3 Mar 2012 at 9:11

  • Added labels: Version-Release3.x

from mybatis.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.