From 612c0606db4cad352bdcd044e31a63762dbde51d Mon Sep 17 00:00:00 2001 From: Vlad Mihalcea Date: Thu, 13 Oct 2016 14:34:35 +0300 Subject: [PATCH] HHH-11066 - Documentation regarding the reason @Filter is not supported with @Cache for collections (cherry picked from commit 95ac619bce1e98e98734f01de832204b13489b65) --- .../userguide/chapters/domain/basic_types.adoc | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/documentation/src/main/asciidoc/userguide/chapters/domain/basic_types.adoc b/documentation/src/main/asciidoc/userguide/chapters/domain/basic_types.adoc index 8849b2a5f7..a3a87d8574 100644 --- a/documentation/src/main/asciidoc/userguide/chapters/domain/basic_types.adoc +++ b/documentation/src/main/asciidoc/userguide/chapters/domain/basic_types.adoc @@ -1383,6 +1383,17 @@ include::{extrasdir}/basic/mapping-filter-collection-query-example.sql[] The main advantage of `@Filter` over teh `@Where` clause is that the filtering criteria can be customized at runtime. ==== +[WARNING] +==== +It's not possible to combine the `@Filter` and `@Cache` collection annotations. +This limitation is due to ensuring consistency and because the filtering information is not stored in the second-level cache. + +If caching was allowed for a currently filtered collection, then the second-level cache would store only a subset of the whole collection. +Afterward, every other Session will get the filtered collection from the cache, even if the Session-level filters have not been explicitly activated. + +For this reason, the second-level collection cache is limited to storing whole collections, and not subsets. +==== + [[mapping-column-any]] ==== @Any mapping