2014年2月5日

[JAVA][JPA] no cache

在persistence.xml 的  <properties>
加入 <property name="toplink.cache.type.default" value="NONE"/>




Default:SoftWeak

The default type of session cache.
A session cache is a shared cache that services clients attached to a given session. When you read objects from or write objects to the data source using a client session, TopLink saves a copy of the objects in the parent server session's cache and makes them accessible to child client sessions.
Valid values: oracle.toplink.essentials.config.CacheType
  • Full - This option provides full caching and guaranteed identity: objects are never flushed from memory unless they are deleted.
    For more information, see Full Identity Map
  • HardWeak - This option is similar to Weak except that it maintains a most frequently used subcache that uses hard references.
    For more information, see Hard Cache Weak Identity Maps
  • NONE - This option does not preserve object identity and does not cache objects. Oracle does not recommend using this option.
    For more information, see No Identity Map.
  • SoftWeak - This option is similar to Weak except that it maintains a most frequently used subcache that uses soft references. Oracle recommends using this identity map in most circumstances as a means to control memory used by the cache.
    For more information, see Soft Cache Weak Identity Maps.
  • Weak - This option is similar to Full, except that objects are referenced using weak references. This option uses less memory than Full, but does not provide a durable caching strategy across client/server transactions. Oracle recommends using this identity map for transactions that, once started, stay on the server side.
    For more information, see Weak Identity Map.
Example: persistence.xml file
<property name="toplink.cache.type.default" value="Full"/>
Example: property Map

import oracle.toplink.essentials.config.CacheType;
import oracle.toplink.essentials.config.TopLinkProperties;
propertiesMap.put(ToplinkProperties.CACHE_TYPE_DEFAULT, CacheType.Full);



toplink cache相關屬性設定:
http://www.oracle.com/technetwork/middleware/ias/toplink-jpa-extensions-094393.html#TopLinkCaching


persistence.xml 相關中文說明
http://publib.boulder.ibm.com/wasce/V3.0.0/zh_TW/jpa.html


沒有留言:

張貼留言