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一個緩存