criteria.setCacheable(true);这个方法是干什么用的

criteria.setCacheable(true);

一下是Criteria的底层源代码

/**
* Enable caching of this query result, provided query caching is enabled
* for the underlying session factory.
*
* @param cacheable Should the result be considered cacheable; default is
* to not cache (false).
* @return this (for method chaining)
*/
public Criteria setCacheable(boolean cacheable);

意思是:

启用查询缓存结果,提供查询缓存
*为底层会话工厂。
*
* @param缓存的结果应该被认为是默认缓存;
*不缓存(false)。
*“退货(方法链接)

就是给criteria一个缓存

原文地址:https://www.cnblogs.com/chengxuy/p/6526454.html