---
title: "OpenJPA2 缓存的问题"
author: "simen_net"
date: "2010-04-02T21:37:48Z"
tags: []
categories: ["企业架构"]
slug: "openjpa2"
draft: false
lastmod: "2010-04-02T21:37:48Z"
id: 631171
url: "https://simen-net.iteye.com/blog/631171"
---

受JPA2的诱惑，最近尝试了一下OpenJPA，在配置缓存的时候都是参考网上的教程来作的：

[http://hi.baidu.com/f1jee/blog/item/68c87b343fa047305ab5f54d.html](http://hi.baidu.com/f1jee/blog/item/68c87b343fa047305ab5f54d.html)

[http://book.51cto.com/art/200806/76706.htm](http://book.51cto.com/art/200806/76706.htm)

虽然看了OpenJPA的文档，但是懒得自己动手写就把代码拷贝了过来，其中：

```
<property name="openjpa.QueryCache" value="CacheSize=1000, SoftReferenceSize=100"/>
```

 使用OpenJPA1.2.2运行非常好，缓存也感觉不错，但是换成OpenJPA2.0beta2之后缓存总是不能用，当时考虑到可能是beta版本的问题，没有太在意，今天发现出了beta3，换了包之后缓存还是不能用。百思不得其解～～～，重新仔细阅读文档也没有发现什么问题。然后～～突然发现好像少了点什么～～原来应该是

```
<property name="openjpa.QueryCache" value="true(CacheSize=1000, SoftReferenceSize=100)"/>
```

 奇怪的是为什么1.2.2的时候能够正常跑，呵呵 看来OpenJPA还没有完全的成熟～～继续测试ing