Java Code Examples for org.hibernate.CacheMode#GET

The following examples show how to use org.hibernate.CacheMode#GET . 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: QueryBinder.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
private static CacheMode getCacheMode(CacheModeType cacheModeType) {
	switch ( cacheModeType ) {
		case GET:
			return CacheMode.GET;
		case IGNORE:
			return CacheMode.IGNORE;
		case NORMAL:
			return CacheMode.NORMAL;
		case PUT:
			return CacheMode.PUT;
		case REFRESH:
			return CacheMode.REFRESH;
		default:
			throw new AssertionFailure( "Unknown cacheModeType: " + cacheModeType );
	}
}
 
Example 2
Source File: CacheModeHelper.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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 3
Source File: CacheModeHelper.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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 4
Source File: CacheModeHelper.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
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 5
Source File: HbmBinder.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static CacheMode getCacheMode(String cacheMode) {
	if (cacheMode == null) return null;
	if ( "get".equals( cacheMode ) ) return CacheMode.GET;
	if ( "ignore".equals( cacheMode ) ) return CacheMode.IGNORE;
	if ( "normal".equals( cacheMode ) ) return CacheMode.NORMAL;
	if ( "put".equals( cacheMode ) ) return CacheMode.PUT;
	if ( "refresh".equals( cacheMode ) ) return CacheMode.REFRESH;
	throw new MappingException("Unknown Cache Mode: " + cacheMode);
}
 
Example 6
Source File: SystemParameterResource.java    From robe with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Return {@link SystemParameter) resource and matches with the given id.
 *
 * @param credentials Injected by {@link RobeAuth} annotation for authentication.
 * @param id          This is  the oid of {@link SystemParameter}
 * @return {@link SystemParameter} resource matches with the given id.
 */
@RobeService(group = "SystemParameter", description = "Return SystemParameter resource.")
@Path("{id}")
@GET
@UnitOfWork(readOnly = true, cacheMode = CacheMode.GET, flushMode = FlushMode.MANUAL)
public SystemParameter get(@RobeAuth Credentials credentials, @PathParam("id") String id) {

    SystemParameter entity = systemParameterDao.findById(id);
    if (entity == null) {
        throw new WebApplicationException(Response.status(404).build());
    }
    return entity;
}
 
Example 7
Source File: UserResource.java    From robe with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Returns all {@link User}s as a collection.
 *
 * @param credentials injected by {@link RobeAuth} annotation for authentication.
 * @return all {@link User}s as a collection with.
 */

@RobeService(group = "User", description = "Returns all Users as a collection.")
@GET
@UnitOfWork(readOnly = true, cacheMode = CacheMode.GET, flushMode = FlushMode.MANUAL)
public List<User> getAll(@RobeAuth Credentials credentials, @SearchParam SearchModel search) {
    return userDao.findAllStrict(search);
}
 
Example 8
Source File: UserResource.java    From robe with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Returns a single User matches with the given id.
 * <p>
 * Status Code:
 * Not Found  404
 *
 * @param credentials injected by {@link RobeAuth} annotation for authentication.
 * @param id          This is the oid of {@link User}
 * @return a {@link User} resource matches with the given id.
 */
@RobeService(group = "User", description = "Returns a User resource matches with the given id.")
@Path("{id}")
@GET
@UnitOfWork(readOnly = true, cacheMode = CacheMode.GET, flushMode = FlushMode.MANUAL)
public User get(@RobeAuth Credentials credentials, @PathParam("id") String id) {
    User entity = userDao.findById(id);
    if (entity == null) {
        throw new WebApplicationException(Response.status(404).build());
    }
    return entity;
}
 
Example 9
Source File: ReactiveSessionImpl.java    From hibernate-reactive with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public boolean isSecondLevelCacheCheckingEnabled() {
	return cacheMode == CacheMode.NORMAL || cacheMode == CacheMode.GET;
}