Greetings!
I'm running into a problem with cache, select statement and trying to
close the session.
When I added <cache /> to my xml maper, I'm getting
org.apache.ibatis.exceptions.PersistenceException. If I comment out
session.close() I get no exceptions, but wonder if session remains
opened.
I came across this problem while trying to make sure that MyBatis
cache is working. I have logging set to DEBUG, but find no mention of
anything getting obtained from cache.
Log displays the following:
[DEBUG,Connection,http-8084-6] ooo Connection Opened
[DEBUG,PreparedStatement,http-8084-6] ==> Executing: select * from
story where id = ?
[DEBUG,PreparedStatement,http-8084-6] ==> Parameters: 4(Integer)
[DEBUG,ResultSet,http-8084-6] <== Columns: title, story,
date_created, last_modified, sub_title, category_id, view_link,
completion, home_page, allow_comments, meta_description,
meta_keywords, id
( ... clipped, the actual body of data selected )
[DEBUG,Connection,http-8084-10] xxx Connection Closed
Could anyone kindly shed some light on what I'm looking at or what I'm
missing?
Many thanks in advance.
MAPPER XML:
<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE mapper PUBLIC "-//
mybatis.org//DTD Mapper 3.0//EN" "
http://mybatis.org/dtd/mybatis-3-
mapper.dtd">
<mapper namespace="bap.persistance.interfaces.ArticleMapper">
<cache />
<select id="selectArticle" parameterType="int" resultType="Article"
> select * from story where id = #{id} </select>
</mapper>
TRYING TO EXECUTE THE SELECT:
try {
ArticleMapper mapper = session.getMapper(ArticleMapper.class);
article = mapper.selectArticle(story_id);
} finally {
session.close();
}
EXCEPTION:
org.springframework.web.util.NestedServletException: Request
processing failed; nested exception is
org.apache.ibatis.exceptions.PersistenceException:
### Error closing transaction. Cause:
org.apache.ibatis.cache.CacheException: Error serializing object.
Cause: java.io.NotSerializableException: bap.domain.Article
### Cause: org.apache.ibatis.cache.CacheException: Error serializing
object. Cause: java.io.NotSerializableException: bap.domain.Article
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:
656)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:
549)
javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:
390)
(... rest clipped for brevity)
ROOT CAUSE:
org.apache.ibatis.exceptions.PersistenceException:
### Error closing transaction. Cause:
org.apache.ibatis.cache.CacheException: Error serializing object.
Cause: java.io.NotSerializableException: bap.domain.Article
### Cause: org.apache.ibatis.cache.CacheException: Error serializing
object. Cause: java.io.NotSerializableException: bap.domain.Article
(... rest clipped for brevity)