Comments (8)
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.
Original comment by [email protected]
on 24 Sep 2010 at 12:18
- Changed state: Accepted
from mybatis.
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.
Original comment by [email protected]
on 24 Sep 2010 at 2:07
- Changed state: Started
from mybatis.
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.
Original comment by [email protected]
on 8 Oct 2010 at 12:23
- Changed state: Fixed
from mybatis.
Original comment by [email protected]
on 8 Oct 2010 at 12:24
- Added labels: Target-Release3.0.3
from mybatis.
Original comment by eduardo.macarron
on 3 Mar 2012 at 9:11
- Added labels: Version-Release3.x
from mybatis.
Related Issues (20)
- [mybatis-spring] Mapper scanning should not rely on proprietary @Mapper annotation HOT 1
- Migrations archive unzips to "ibatis-migrations" instead of "mybatis-migrations" HOT 2
- OSGI Support HOT 4
- Remove mapper order restriction when referencing SQL fragment in another file. HOT 40
- Non-existent object id is incorrectly resolved when there is an entry with the same short name. HOT 13
- Allow applying @Transactional to types and interfaces and add a @NoTransaction attribute HOT 4
- Please prioritize issues HOT 1
- Adjust issue's status HOT 1
- Unable to get auto-generated ID with mysql using annotations HOT 1
- Mybatis-spring doesn't propagate exceptions up the stack when using batch mode HOT 17
- how to free temp tablespace allocated for a select stmt return parameter HOT 1
- rollback on BatchExecutor executes batched statements HOT 8
- resultMap doesn't support mapping of unnamed columns by index HOT 2
- mybatis3.0.3 bug in WebService ?? HOT 2
- Annotation-based and AOP-based sessions HOT 3
- Global parameter typeHandler not invoked in case of null values HOT 2
- Exception: Result Maps collection does not contain value for test.User-result HOT 2
- Handling of update counts before result sets in select HOT 8
- configure behavior when all columns values are null for some rows HOT 5
- queryForMap does not use a column as map HOT 14
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mybatis.