Java Code Examples for javax.persistence.CacheRetrieveMode#USE
The following examples show how to use
javax.persistence.CacheRetrieveMode#USE .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CacheModeHelper.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Given a JPA {@link CacheStoreMode} and {@link CacheRetrieveMode}, determine the corresponding * legacy Hibernate {@link CacheMode}. * * @param storeMode The JPA shared-cache store mode. * @param retrieveMode The JPA shared-cache retrieve mode. * * @return Corresponding {@link CacheMode}. */ public static CacheMode interpretCacheMode(CacheStoreMode storeMode, CacheRetrieveMode retrieveMode) { if ( storeMode == null ) { storeMode = DEFAULT_STORE_MODE; } if ( retrieveMode == null ) { retrieveMode = DEFAULT_RETRIEVE_MODE; } final boolean get = ( CacheRetrieveMode.USE == retrieveMode ); switch ( storeMode ) { case USE: { return get ? CacheMode.NORMAL : CacheMode.PUT; } case REFRESH: { // really (get == true) here is a bit of an invalid combo... return CacheMode.REFRESH; } case BYPASS: { return get ? CacheMode.GET : CacheMode.IGNORE; } default: { throw new IllegalStateException( "huh? :)" ); } } }
Example 2
Source File: CacheModeHelper.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Given a JPA {@link CacheStoreMode} and {@link CacheRetrieveMode}, determine the corresponding * legacy Hibernate {@link CacheMode}. * * @param storeMode The JPA shared-cache store mode. * @param retrieveMode The JPA shared-cache retrieve mode. * * @return Corresponding {@link CacheMode}. */ public static CacheMode effectiveCacheMode(CacheStoreMode storeMode, CacheRetrieveMode retrieveMode) { if ( storeMode == null && retrieveMode == null ) { return null; } if ( storeMode == null ) { storeMode = DEFAULT_STORE_MODE; } if ( retrieveMode == null ) { retrieveMode = DEFAULT_RETRIEVE_MODE; } final boolean get = ( CacheRetrieveMode.USE == retrieveMode ); switch ( storeMode ) { case USE: { return get ? CacheMode.NORMAL : CacheMode.PUT; } case REFRESH: { // really (get == true) here is a bit of an invalid combo... return CacheMode.REFRESH; } case BYPASS: { return get ? CacheMode.GET : CacheMode.IGNORE; } default: { throw new IllegalStateException( "huh? :)" ); } } }
Example 3
Source File: CacheModeHelper.java From lams with GNU General Public License v2.0 | 5 votes |
public static CacheRetrieveMode interpretCacheRetrieveMode(CacheMode cacheMode) { if ( cacheMode == null ) { cacheMode = DEFAULT_LEGACY_MODE; } return ( CacheMode.NORMAL == cacheMode || CacheMode.GET == cacheMode ) ? CacheRetrieveMode.USE : CacheRetrieveMode.BYPASS; }
Example 4
Source File: CacheConfig.java From devicehive-java-server with Apache License 2.0 | 4 votes |
/** * get entities from cache */ public static CacheConfig get() { return new CacheConfig(CacheRetrieveMode.USE, CacheStoreMode.USE); }
Example 5
Source File: CacheConfig.java From devicehive-java-server with Apache License 2.0 | 4 votes |
/** * get entities from db and refresh cache */ public static CacheConfig refresh() { return new CacheConfig(CacheRetrieveMode.USE, CacheStoreMode.REFRESH); }