自定义用户类型在Hibernate的二级缓存中

时间:2016-03-20 12:50:11

标签: java hibernate jpa caching ehcache

我对用户类型使用hibernate(4.3.11.Final),ehcache(2.10.1)和jadira(5.0.0.GA)。
有没有办法用joda LocalDateTime存储在缓存实体中?
例如。实现自定义用户类型或调整SizeOfEngine?

@Entity
public class Person {
    @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentLocalDateTime")
    private LocalDateTime createDate;
}

public class PersonRepository implements JpaRepository<Person, Long> {
  @Cacheable("PersonCache")
  Person getOne(Long id);
}

Ehcache config

<?xml version="1.0" encoding="UTF-8"?>
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd"
         name="CM1"
         updateCheck="false"
         maxBytesLocalHeap="16M">

  <diskStore path="java.io.tmpdir"/>

  <cache name="PersonCache" eternal="false">

</ehcache>

Ehcahe的SizeOfEngine警告日志:

net.sf.ehcache.pool.sizeof.ObjectGraphWalker - The configured limit of 1 000 object references was reached while attempting to calculate the size of the object graph.

相关问题:herehere

0 个答案:

没有答案
相关问题