In my tapestry/spring/hibernate3 pages, I've been seeing some strange behavior with some queries and collections not being cached although all the parameters are set to cache them.
Is there any simple reason for this behavior?
Code:
String query = "from Article ar where ar.famille = :fam"
+ " and ar.AR_Publie = 1";
if (C_CL_DESIGN.equals(classement)) {
query = query.concat(" order by ar.AR_Design");
} else if (C_CL_MONTANT.equals(classement)) {
query = query.concat(" order by ar.prixVteTtc");
}
s_logger.debug("Query=" + query);
Query queryObject = session.createQuery(query);
queryObject.setParameter("fam", fam);
queryObject.setCacheable(true);
return queryObject.list();
And there is the log in debug with the second and third invocation of the same query:
02:57:14,493 DEBUG SessionImpl:768 - find: select ar from Article ar where ar.famille = :fam and ar.AR_Publie = 1 and (ar.AR_Stat01 = :niv1 or ar.AR_Stat01 = :niv2) order by ar.AR_Design
02:57:14,493 DEBUG QueryParameters:207 - named parameters: {niv1=1, niv2=2, fam=actualis.web.bo.catalogue.Famille#CARTESTV}
02:57:14,493 DEBUG QueryTranslatorImpl:113 - compile() : The query is already compiled, skipping...
02:57:14,493 DEBUG StandardQueryCache:73 - checking cached query results in region: org.hibernate.cache.StandardQueryCache
02:57:14,493 DEBUG EhCache:104 - key: sql: select article0_.ref as ref, article0_.sync_state as sync2_0_, article0_.nom as nom0_, article0_.codefam as codefam0_, article0_.substitut as substitut0_, article0_.garantie as garantie0_, article0_.poids_net as poids7_0_, article0_.poids_brut as poids8_0_, article0_.unite_vte as unite9_0_, article0_.prix_vteHT as prix10_0_, article0_.prix_vteTTC as prix11_0_, article0_.suivi_stock as suivi12_0_, article0_.stat1 as stat13_0_, article0_.stat2 as stat14_0_, article0_.stat3 as stat15_0_, article0_.stat4 as stat16_0_, article0_.stat5 as stat17_0_, article0_.delai_livraison as delai18_0_, article0_.code_fiscal as code19_0_, article0_.pays_origine as pays20_0_, article0_.fac_poids as fac21_0_, article0_.date_creation as date22_0_, article0_.date_modification as date23_0_, article0_.publie as publie0_, article0_.prix_achat as prix25_0_, article0_.prix_achat_coef as prix26_0_ from articles article0_ where (article0_.codefam=? and article0_.publie=1 and (article0_.stat1=? or article0_.stat1=?)) order by article0_.nom; parameters: ; named parameters: {niv1=1, niv2=2, fam=actualis.web.bo.catalogue.Famille@1b18235[FA_CodeFamille=CARTESTV]}
02:57:14,493 DEBUG EhCache:113 - Element for sql: select article0_.ref as ref, article0_.sync_state as sync2_0_, article0_.nom as nom0_, article0_.codefam as codefam0_, article0_.substitut as substitut0_, article0_.garantie as garantie0_, article0_.poids_net as poids7_0_, article0_.poids_brut as poids8_0_, article0_.unite_vte as unite9_0_, article0_.prix_vteHT as prix10_0_, article0_.prix_vteTTC as prix11_0_, article0_.suivi_stock as suivi12_0_, article0_.stat1 as stat13_0_, article0_.stat2 as stat14_0_, article0_.stat3 as stat15_0_, article0_.stat4 as stat16_0_, article0_.stat5 as stat17_0_, article0_.delai_livraison as delai18_0_, article0_.code_fiscal as code19_0_, article0_.pays_origine as pays20_0_, article0_.fac_poids as fac21_0_, article0_.date_creation as date22_0_, article0_.date_modification as date23_0_, article0_.publie as publie0_, article0_.prix_achat as prix25_0_, article0_.prix_achat_coef as prix26_0_ from articles article0_ where (article0_.codefam=? and article0_.publie=1 and (article0_.stat1=? or article0_.stat1=?)) order by article0_.nom; parameters: ; named parameters: {niv1=1, niv2=2, fam=actualis.web.bo.catalogue.Famille@1b18235[FA_CodeFamille=CARTESTV]} is null
02:57:14,508 DEBUG StandardQueryCache:76 -
query results were not found in cache
...
03:09:59,477 DEBUG SessionImpl:768 - find: select ar from Article ar where ar.famille = :fam and ar.AR_Publie = 1 and (ar.AR_Stat01 = :niv1 or ar.AR_Stat01 = :niv2) order by ar.AR_Design
03:09:59,477 DEBUG QueryParameters:207 - named parameters: {niv1=1, niv2=2, fam=actualis.web.bo.catalogue.Famille#CARTESTV}
03:09:59,477 DEBUG QueryTranslatorImpl:113 - compile() : The query is already compiled, skipping...
03:09:59,477 DEBUG StandardQueryCache:73 - checking cached query results in region: org.hibernate.cache.StandardQueryCache
03:09:59,477 DEBUG EhCache:104 - key: sql: select article0_.ref as ref, article0_.sync_state as sync2_0_, article0_.nom as nom0_, article0_.codefam as codefam0_, article0_.substitut as substitut0_, article0_.garantie as garantie0_, article0_.poids_net as poids7_0_, article0_.poids_brut as poids8_0_, article0_.unite_vte as unite9_0_, article0_.prix_vteHT as prix10_0_, article0_.prix_vteTTC as prix11_0_, article0_.suivi_stock as suivi12_0_, article0_.stat1 as stat13_0_, article0_.stat2 as stat14_0_, article0_.stat3 as stat15_0_, article0_.stat4 as stat16_0_, article0_.stat5 as stat17_0_, article0_.delai_livraison as delai18_0_, article0_.code_fiscal as code19_0_, article0_.pays_origine as pays20_0_, article0_.fac_poids as fac21_0_, article0_.date_creation as date22_0_, article0_.date_modification as date23_0_, article0_.publie as publie0_, article0_.prix_achat as prix25_0_, article0_.prix_achat_coef as prix26_0_ from articles article0_ where (article0_.codefam=? and article0_.publie=1 and (article0_.stat1=? or article0_.stat1=?)) order by article0_.nom; parameters: ; named parameters: {niv1=1, niv2=2, fam=actualis.web.bo.catalogue.Famille@10794d4[FA_CodeFamille=CARTESTV]}
03:09:59,477 DEBUG EhCache:113 - Element for sql: select article0_.ref as ref, article0_.sync_state as sync2_0_, article0_.nom as nom0_, article0_.codefam as codefam0_, article0_.substitut as substitut0_, article0_.garantie as garantie0_, article0_.poids_net as poids7_0_, article0_.poids_brut as poids8_0_, article0_.unite_vte as unite9_0_, article0_.prix_vteHT as prix10_0_, article0_.prix_vteTTC as prix11_0_, article0_.suivi_stock as suivi12_0_, article0_.stat1 as stat13_0_, article0_.stat2 as stat14_0_, article0_.stat3 as stat15_0_, article0_.stat4 as stat16_0_, article0_.stat5 as stat17_0_, article0_.delai_livraison as delai18_0_, article0_.code_fiscal as code19_0_, article0_.pays_origine as pays20_0_, article0_.fac_poids as fac21_0_, article0_.date_creation as date22_0_, article0_.date_modification as date23_0_, article0_.publie as publie0_, article0_.prix_achat as prix25_0_, article0_.prix_achat_coef as prix26_0_ from articles article0_ where (article0_.codefam=? and article0_.publie=1 and (article0_.stat1=? or article0_.stat1=?)) order by article0_.nom; parameters: ; named parameters: {niv1=1, niv2=2, fam=actualis.web.bo.catalogue.Famille@10794d4[FA_CodeFamille=CARTESTV]} is null
03:09:59,477 DEBUG StandardQueryCache:76 -
query results were not found in cache
...
Henri