Quantcast

about mybatis config memcached and when excute insert method throw exception

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

about mybatis config memcached and when excute insert method throw exception

bluce awen
when execute insertUser method, i got an exception.  
It looks like the UserEntity which insert into database is null.
The fileds in UserEntity are set value except update_date which is null.
 

<mapper namespace="com.server.repository.mapper.UserMapper" >

<cache type="org.mybatis.caches.memcached.LoggingMemcachedCache" />

<resultMap type="UserEntity" id="userResultMap">
<result property="id" column="id"/>
<result property="userName" column="user_name" />
<result property="userPwd" column="user_pwd" />
<result property="createDate" column="create_date" />
<result property="updateDate" column="update_date" />
<result property="lastLoginDate" column="last_login_date"/>
<result property="deleteFlag" column="delete_flag"/>
</resultMap>

<insert id="insertUser" >
insert into tb_user (
id, user_name, user_pwd, user_area_code, create_date, update_date
)
values (
#{user.id}, #{user.userName}, #{user.userPwd}, #{user.userAreaCode}, #{user.createDate}, #{user.updateDate}
)
</insert>

</mapper>


Caused by: org.apache.ibatis.exceptions.PersistenceException: 
### Error committing transaction.  Cause: java.lang.NullPointerException: Can't serialize null
### Cause: java.lang.NullPointerException: Can't serialize null
at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
at org.apache.ibatis.session.defaults.DefaultSqlSession.commit(DefaultSqlSession.java:227)
at org.apache.ibatis.session.defaults.DefaultSqlSession.commit(DefaultSqlSession.java:218)
at org.mybatis.spring.SqlSessionUtils$SqlSessionSynchronization.beforeCommit(SqlSessionUtils.java:286)
... 91 more
Caused by: java.lang.NullPointerException: Can't serialize null
at net.spy.memcached.transcoders.BaseSerializingTranscoder.serialize(BaseSerializingTranscoder.java:97)
at net.spy.memcached.transcoders.SerializingTranscoder.encode(SerializingTranscoder.java:162)
at net.spy.memcached.MemcachedClient.asyncStore(MemcachedClient.java:305)
at net.spy.memcached.MemcachedClient.set(MemcachedClient.java:929)
at org.mybatis.caches.memcached.MemcachedClientWrapper.storeInMemcached(MemcachedClientWrapper.java:222)
at org.mybatis.caches.memcached.MemcachedClientWrapper.putObject(MemcachedClientWrapper.java:185)
at org.mybatis.caches.memcached.MemcachedCache.putObject(MemcachedCache.java:89)
at org.apache.ibatis.cache.decorators.LoggingCache.putObject(LoggingCache.java:51)
at org.apache.ibatis.cache.decorators.TransactionalCache.flushPendingEntries(TransactionalCache.java:126)
at org.apache.ibatis.cache.decorators.TransactionalCache.commit(TransactionalCache.java:105)
at org.apache.ibatis.cache.TransactionalCacheManager.commit(TransactionalCacheManager.java:44)
at org.apache.ibatis.executor.CachingExecutor.commit(CachingExecutor.java:120)
at org.apache.ibatis.session.defaults.DefaultSqlSession.commit(DefaultSqlSession.java:224)
... 93 more

Thank you .

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: about mybatis config memcached and when excute insert method throw exception

Guy Rouillier-2
Some observations:

(1) Why are you including resultMap?  Those are only used for queries; they map a ResultSet, which is why it is called a resultMap.  I just want to make sure you aren't thinking that MyBatis is somehow using the resultMap to map your incoming object into your insert statement.

(2) You are not specifying the parameterType on your insert statement.

(3) Why are you including update_date on your insert statement, if you know that the updateDate coming from your program is null?  Should work, but if you read the MyBatis User Guide, you will need to specify at a minimum the jdbcType for parameters that can be null.  Once you address item (2), you'll probably get a new error message to this effect.

--
Guy Rouillier



------ Original Message ------
From: "bluce awen" <[hidden email]>
To: "mybatis-user" <[hidden email]>
Sent: 3/5/2017 5:25:11 AM
Subject: about mybatis config memcached and when excute insert method throw exception

when execute insertUser method, i got an exception.  
It looks like the UserEntity which insert into database is null.
The fileds in UserEntity are set value except update_date which is null.
 

<mapper namespace="com.server.repository.mapper.UserMapper" >

<cache type="org.mybatis.caches.memcached.LoggingMemcachedCache" />

<resultMap type="UserEntity" id="userResultMap">
<result property="id" column="id"/>
<result property="userName" column="user_name" />
<result property="userPwd" column="user_pwd" />
<result property="createDate" column="create_date" />
<result property="updateDate" column="update_date" />
<result property="lastLoginDate" column="last_login_date"/>
<result property="deleteFlag" column="delete_flag"/>
</resultMap>

<insert id="insertUser" >
insert into tb_user (
id, user_name, user_pwd, user_area_code, create_date, update_date
)
values (
#{user.id}, #{user.userName}, #{user.userPwd}, #{user.userAreaCode}, #{user.createDate}, #{user.updateDate}
)
</insert>

</mapper>


Caused by: org.apache.ibatis.exceptions.PersistenceException: 
### Error committing transaction.  Cause: java.lang.NullPointerException: Can't serialize null
### Cause: java.lang.NullPointerException: Can't serialize null
at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
at org.apache.ibatis.session.defaults.DefaultSqlSession.commit(DefaultSqlSession.java:227)
at org.apache.ibatis.session.defaults.DefaultSqlSession.commit(DefaultSqlSession.java:218)
at org.mybatis.spring.SqlSessionUtils$SqlSessionSynchronization.beforeCommit(SqlSessionUtils.java:286)
... 91 more
Caused by: java.lang.NullPointerException: Can't serialize null
at net.spy.memcached.transcoders.BaseSerializingTranscoder.serialize(BaseSerializingTranscoder.java:97)
at net.spy.memcached.transcoders.SerializingTranscoder.encode(SerializingTranscoder.java:162)
at net.spy.memcached.MemcachedClient.asyncStore(MemcachedClient.java:305)
at net.spy.memcached.MemcachedClient.set(MemcachedClient.java:929)
at org.mybatis.caches.memcached.MemcachedClientWrapper.storeInMemcached(MemcachedClientWrapper.java:222)
at org.mybatis.caches.memcached.MemcachedClientWrapper.putObject(MemcachedClientWrapper.java:185)
at org.mybatis.caches.memcached.MemcachedCache.putObject(MemcachedCache.java:89)
at org.apache.ibatis.cache.decorators.LoggingCache.putObject(LoggingCache.java:51)
at org.apache.ibatis.cache.decorators.TransactionalCache.flushPendingEntries(TransactionalCache.java:126)
at org.apache.ibatis.cache.decorators.TransactionalCache.commit(TransactionalCache.java:105)
at org.apache.ibatis.cache.TransactionalCacheManager.commit(TransactionalCacheManager.java:44)
at org.apache.ibatis.executor.CachingExecutor.commit(CachingExecutor.java:120)
at org.apache.ibatis.session.defaults.DefaultSqlSession.commit(DefaultSqlSession.java:224)
... 93 more

Thank you .

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

Virus-free. www.avast.com

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Loading...