本文整理汇总了Java中org.hibernate.CacheMode.valueOf方法的典型用法代码示例。如果您正苦于以下问题:Java CacheMode.valueOf方法的具体用法?Java CacheMode.valueOf怎么用?Java CacheMode.valueOf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.hibernate.CacheMode
的用法示例。
在下文中一共展示了CacheMode.valueOf方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readObject
import org.hibernate.CacheMode; //导入方法依赖的package包/类
/**
* Used by JDK serialization...
*
* @param ois The input stream from which we are being read...
* @throws IOException Indicates a general IO stream exception
* @throws ClassNotFoundException Indicates a class resolution issue
*/
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
LOG.trace( "Deserializing session" );
ois.defaultReadObject();
entityNameResolver = new CoordinatingEntityNameResolver();
connectionReleaseMode = ConnectionReleaseMode.parse( ( String ) ois.readObject() );
autoClear = ois.readBoolean();
autoJoinTransactions = ois.readBoolean();
flushMode = FlushMode.valueOf( ( String ) ois.readObject() );
cacheMode = CacheMode.valueOf( ( String ) ois.readObject() );
flushBeforeCompletionEnabled = ois.readBoolean();
autoCloseSessionEnabled = ois.readBoolean();
interceptor = ( Interceptor ) ois.readObject();
factory = SessionFactoryImpl.deserialize( ois );
sessionOwner = ( SessionOwner ) ois.readObject();
transactionCoordinator = TransactionCoordinatorImpl.deserialize( ois, this );
persistenceContext = StatefulPersistenceContext.deserialize( ois, this );
actionQueue = ActionQueue.deserialize( ois, this );
loadQueryInfluencers = (LoadQueryInfluencers) ois.readObject();
// LoadQueryInfluencers.getEnabledFilters() tries to validate each enabled
// filter, which will fail when called before FilterImpl.afterDeserialize( factory );
// Instead lookup the filter by name and then call FilterImpl.afterDeserialize( factory ).
for ( String filterName : loadQueryInfluencers.getEnabledFilterNames() ) {
((FilterImpl) loadQueryInfluencers.getEnabledFilter( filterName )).afterDeserialize( factory );
}
}
示例2: execute
import org.hibernate.CacheMode; //导入方法依赖的package包/类
@Override
public <E> E execute(OnlineSectioningAction<E> action, OnlineSectioningLog.Entity user) throws SectioningException {
long c0 = OnlineSectioningHelper.getCpuTime();
String cacheMode = getConfig().getProperty(action.name() + ".CacheMode", getConfig().getProperty("CacheMode"));
OnlineSectioningHelper h = new OnlineSectioningHelper(user, cacheMode != null ? CacheMode.valueOf(cacheMode) : action instanceof HasCacheMode ? ((HasCacheMode)action).getCacheMode() : CacheMode.IGNORE);
try {
setCurrentHelper(h);
h.addMessageHandler(new OnlineSectioningHelper.DefaultMessageLogger(LogFactory.getLog(action.getClass().getName() + "." + action.name() + "[" + getAcademicSession().toCompactString() + "]")));
h.addAction(action, getAcademicSession());
E ret = action.execute(this, h);
if (h.getAction() != null && !h.getAction().hasResult()) {
if (ret == null)
h.getAction().setResult(OnlineSectioningLog.Action.ResultType.NULL);
else if (ret instanceof Boolean)
h.getAction().setResult((Boolean)ret ? OnlineSectioningLog.Action.ResultType.TRUE : OnlineSectioningLog.Action.ResultType.FALSE);
else
h.getAction().setResult(OnlineSectioningLog.Action.ResultType.SUCCESS);
}
return ret;
} catch (Exception e) {
if (e instanceof SectioningException) {
if (e.getCause() == null) {
h.info("Execution failed: " + e.getMessage());
} else {
h.warn("Execution failed: " + e.getMessage(), e.getCause());
}
} else {
h.error("Execution failed: " + e.getMessage(), e);
}
if (h.getAction() != null) {
h.getAction().setResult(OnlineSectioningLog.Action.ResultType.FAILURE);
if (e.getCause() != null && e instanceof SectioningException)
h.getAction().addMessage(OnlineSectioningLog.Message.newBuilder()
.setLevel(OnlineSectioningLog.Message.Level.FATAL)
.setText(e.getCause().getClass().getName() + ": " + e.getCause().getMessage()));
else
h.getAction().addMessage(OnlineSectioningLog.Message.newBuilder()
.setLevel(OnlineSectioningLog.Message.Level.FATAL)
.setText(e.getMessage() == null ? "null" : e.getMessage()));
}
if (e instanceof SectioningException)
throw (SectioningException)e;
throw new SectioningException(MSG.exceptionUnknown(e.getMessage()), e);
} finally {
if (h.getAction() != null) {
h.getAction().setEndTime(System.currentTimeMillis()).setCpuTime(OnlineSectioningHelper.getCpuTime() - c0);
if ((!h.getAction().hasStudent() || !h.getAction().getStudent().hasExternalId()) &&
user != null && user.hasExternalId() &&
user.hasType() && user.getType() == OnlineSectioningLog.Entity.EntityType.STUDENT) {
if (h.getAction().hasStudent()) {
h.getAction().getStudentBuilder().setExternalId(user.getExternalId());
} else {
h.getAction().setStudent(OnlineSectioningLog.Entity.newBuilder().setExternalId(user.getExternalId()));
}
}
}
if (iLog.isDebugEnabled())
iLog.debug("Executed: " + h.getLog() + " (" + h.getLog().toByteArray().length + " bytes)");
OnlineSectioningLogger.getInstance().record(h.getLog());
releaseCurrentHelper();
}
}
示例3: getCacheMode
import org.hibernate.CacheMode; //导入方法依赖的package包/类
protected CacheMode getCacheMode() {
String cacheMode = (getName() != null && !getName().isEmpty() ? ApplicationProperty.ApiCacheMode.value(getName()) : null);
return cacheMode != null ? CacheMode.valueOf(cacheMode) : this instanceof HasCacheMode ? ((HasCacheMode)this).getCacheMode() : null;
}