zwllxs
2019-01-03 20:16spring data jpa, 分页查询加缓存时,PageImpl 无法反序列化
由于想给 findAll(Pageable pageable)加上spring的缓存(spring cache),第一遍查询正常,但是在第二遍以后,从缓存中读取时,无法反序列化,提示没有无参构造,请问这个有解决办法吗?
如下:
@CacheConfig(cacheNames = {"familyUserDao"})
public interface FamilyUserDao extends JpaRepository<FamilyUser,Long> {
@Override
@Cacheable(key = "methodName +#p0")
Page<FamilyUser> findAll(Pageable pageable);
}
调用 :
Page<FamilyUser> familyUserPage = familyUserDao.findAll(pageable);
时,报:
org.springframework.data.redis.serializer.SerializationException: Could not read JSON: Can not construct instance of org.springframework.data.domain.PageImpl: no suitable constructor found, can not deserialize from Object value (missing default constructor or creator, or perhaps need to add/enable type information?)
at [Source: [B@7fae8571; line: 1, column: 46]; nested exception is com.fasterxml.jackson.databind.JsonMappingException: Can not construct instance of org.springframework.data.domain.PageImpl: no suitable constructor found, can not deserialize from Object value (missing default constructor or creator, or perhaps need to add/enable type information?)
at [Source: [B@7fae8571; line: 1, column: 46]
at org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer.deserialize(Jackson2JsonRedisSerializer.java:73),
这里其实是反序列化问题,jpa默认是使用PageImpl实现Page,
但是PageImpl并没有无参构造,如下:
有办法完美解决吗?
没有C币,一是分享问题,二是只能乞求大家看看有没有好办法啦,多谢啦
- 点赞
- 回答
- 收藏
- 复制链接分享
1条回答
为你推荐
- SpingBoot+Jpa 死锁问题
- spring
- maven
- hibernate
- eclipse
- java-ee
- 1个回答
- 使用spring data jpa的问题,依赖包版本
- it技术
- 互联网问答
- IT行业问题
- 计算机技术
- 编程语言问答
- 0个回答
- spring-data-jpa delete
- spring
- hibernate
- 0个回答
- spring data jpa 的一些疑问
- spring
- 0个回答
- Spring Data Jpa怎么多表join查询
- spring
- jpa
- 6个回答
换一换