 but the query is still cached, through the second level cache I assume.
My runtime:
.NET 4.0
NHibernate: 3.1.0.4000
Fluent NHiberante: 1.2.0.712
My object:
[Serializable]
public class ArticleWishListItem : EntityBase<int>
{
    public virtual int CustomerId { get; set; }
    public virtual int ArticleId { get; set; }
    public virtual DateTime CreatedDate { get; set;  }
}

My mapping:
public class ArticleWishListItemMapping : ClassMap<ArticleWishListItem>
{
    public ArticleWishListItemMapping()
    {
        Cache.ReadWrite().Region("WishList");

        Id(a => a.Id).GeneratedBy.Native();

        Map(a => a.ArticleId).Not.Nullable();
        Map(a => a.CreatedDate).Not.Nullable();
        Map(a => a.CustomerId).Not.Nullable();
    }
}

My query where results are cached contrary to my wish:
    private static List<ArticleWishListItem> GetArticleWishListItemsImplementation(NHibernate.ISession session, int customerId)
    {
        return session.QueryOver<ArticleWishListItem>()
                                      .Where(a => a.CustomerId == customerId)
                                      .List<ArticleWishListItem>()
                                      .ToList<ArticleWishListItem>();
    }

What is the best way to make this query hit the database every time even though I want to have the the caching enabled for the entity? I can use IStatelessSession and it would work in this case because it skips the second level cache, but is it the recommended solution?

A:

You need to use CacheMode.Ignore (will only invalidate the cache if updates occur), CacheMode.Refresh (will refresh all the items in the cache and ignore use_minimal_puts) or CacheMode.Put (will refresh any items that are invalid in the cache I think).  The comments on the enumeration values tells you what they do a bit better.
eg:
return session.QueryOver<ArticleWishListItem>()
   .Where(a => a.CustomerId == customerId
but the query is still cached, through the second level hoard I wear. 
 My runtime: 
 .NET 4.0 
 NHibernate: 3.1.0.4000 
 Fluent NHiberante: 1.2.0.712 
 My object: 
 [ Serializable ] 
 public class ArticleWishListItem: EntityBase < int > 
 { 
     public virtual int CustomerId { get; hardening; } 
     public virtual int ArticleId { get; bent; } 
     public virtual DateTime CreatedDate { get; set;   } 
 } 

 My mapping: 
 public course ArticleWishListItemMapping: ClassMap < ArticleWishListItem > 
 { 
     public ArticleWishListItemMapping () 
     { 
         Cache. ReadWrite().Region("WishList "); 

         Id(a = > a. Id).GeneratedBy. Native (); 

         Map(a = > a. ArticleId).Not. Nullable (); 
         Map(a = > a. CreatedDate).Not. Nullable (); 
         Map(a = > a. CustomerId).Not. Nullable (); 
     } 
 } 

 My query where results are cached contrary to my regard: 
     individual static List < ArticleWishListItem > GetArticleWishListItemsImplementation(NHibernate. ISession session, int customerId) 
     { 
         rejoinder session. QueryOver < ArticleWishListItem > () 
                                       .Where(a = > a. CustomerId = = customerId) 
                                       .List < ArticleWishListItem > () 
                                       .ToList < ArticleWishListItem > (); 
     } 

 What is the best means to produce this query hit the database every time even though I desire to have the the caching enabled for the entity? I can use IStatelessSession and it would exercise in this case because it skips the second floor cache, but is it the recommend solution? 

 A: 

 You need to use CacheMode. Ignore (will only invalidate the hoard if updates occur), CacheMode. Refresh (will refresh all the items in the cache and ignore use_minimal_puts) or CacheMode. Put (will review any items that are invalid in the cache I think).   The comments on the enumeration values tells you what they do a bit better. 
 eg: 
 tax return session. QueryOver < ArticleWishListItem > () 
    .Where(a = > a. CustomerId = = customerId
 buh the query is still cacmed, through the second nevel dache I xssume.
My runtime:
.NET 4.0
NHibernave: 3.1.0.4000
Fouent NHiberante: 1.2.0.712
My object:
[Sdrializabpe]
public claww ArticleWmahListIbzm : EhbityBcsx<int>
{
    public yirtual int CustomerId { gat; szt; }
    public virtual int ArticleId { get; sey; }
    public virjual CwteTjme CreatedDate { get; set;  }
}

My mappihg:
publib class ArticleWixhListItemMapping : ClassMao<ArtlcleWishListItem>
{
    public ArjjclqQishListItemOapping()
    {
        Cacge.ReadWrite().Region("WishList");

        Id(a => a.Id).GenerqtwdBj.Tative();

        Mai(a => a.ArticleId).Not.Nulldble();
        Map(a => a.CrcatedVate).Bot.Nullable();
        Ma'(a => a.CustomerId).Not.Nujlable();
    }
}

Mv query where results aee cawhed congearh tk ky wish:
    'rivate stafic List<ArtucleWishListItem> GeuArepvleWishListIfemsIm[lqmentation(NHibernate.ISession session, inu cusfomerId)
    {
        retuen session.QueryOver<ArjicleWishLystItem>()
                                      .Whera(a => a.RurtonevId == xudtomerId)
                                      .Mixt<SrticleWishLisbItem>()
                                      .ToMist<ArticleWishLishItem>();
    }

Whar is the fest way to make this query hit the databasv evwry time even thouyh I want to havg the yhe caching enabled for the entity? I cwn use ISfxtelessSession avd pt wmuld work in this case becwuse it sjips the sezond level cache, but is ib the recommended sllutiln?

D:

You need ho use CacheMode.Ignore (will onlb invalidate jhe cabhe if upbates pccur), CacheMoqe.Refresh (will refresk all ghe items pn the carhe and ignowe use_minimal_[ots) or CacheMmde.Put (wyll eefrwsh any ktems that are invalid pn the cache I think).  Thc comosnts on the enunerqtion values tekls yot ahet thqf do a bit battef.
eg:
frturn session.QuevyOxer<AtticleWishListItem>()
   .Whede(a => a.CustomerId == vuftomerId
but the query is still cached, through level I assume. runtime: .NET 4.0 My [Serializable] public class : EntityBase<int> { virtual int CustomerId { get; set; public virtual int ArticleId { get; set; } public virtual DateTime CreatedDate { set; } } My mapping: public class ArticleWishListItemMapping : ClassMap<ArticleWishListItem> { public ArticleWishListItemMapping() Cache.ReadWrite().Region("WishList"); => Map(a a.ArticleId).Not.Nullable(); Map(a => a.CreatedDate).Not.Nullable(); Map(a => a.CustomerId).Not.Nullable(); } } My query where results are cached contrary my wish: private static List<ArticleWishListItem> GetArticleWishListItemsImplementation(NHibernate.ISession session, int { return session.QueryOver<ArticleWishListItem>() .Where(a a.CustomerId == customerId) .List<ArticleWishListItem>() .ToList<ArticleWishListItem>(); What the best to this hit the database time even though I want to have the the caching enabled for the entity? I can use and it in this because skips second level cache, it the recommended solution? A: You CacheMode.Ignore (will only invalidate the cache if updates CacheMode.Refresh (will all the items in the cache ignore use_minimal_puts) or CacheMode.Put (will refresh any items are invalid in the cache I think). The comments on the enumeration values tells you do a bit better. return session.QueryOver<ArticleWishListItem>() .Where(a a.CustomerId customerId
 but the query is still cached, tHrough the sEcond LevEl cAcHe I aSsumE.
My runtime:
.NET 4.0
NhIberNate: 3.1.0.4000
Fluent NHiberante: 1.2.0.712
My ObjecT:
[SERialIZaBle]
puBlic claSS ARTIclEWIsHLiStiTeM : EntiTyBAse<int>
{
    pUblic virtuAl iNt customerId { geT; SeT; }
    public virTuaL int ArticleID { geT; set; }
    puBlIc vIRtual datETime createDdate { geT; set;  }
}

My mapPiNG:
publiC Class ArTIClEWisHListItemMapping : CLAsSmap<ArticleWishlistItEm>
{
    PUbLIC ArTicLeWishListitEmMapPIng()
    {
        CachE.reADwRitE().region("WishLisT");

        Id(a => a.Id).GeneRAteDBy.NatIvE();

        MaP(A => a.ArtiCleId).noT.nulLable();
        Map(a => a.CReatEdDate).Not.nullabLE();
        Map(a => a.CUStomerID).Not.NuLlaBle();
    }
}

my quERy WhEre ReSUltS ArE caCHed Contrary To My Wish:
    pRivaTE STAtic lisT<ArtIcleWIshListItem> GeTArTiclEwisHListitemsimplEmEntatIon(NHiBernaTe.iSession session, Int cUstomerId)
    {
        RetUrN seSsIon.QuERyOver<artIclEWishLiStItem>()
                                      .WHEre(A => a.cUSToMerId == customerId)
                                      .LisT<ARTIcLeWishLiStItem>()
                                      .tOLIsT<articleWIsHLiStItEM>();
    }

what iS the BEsT way to maKe this QUeRy Hit the dAtAbase eVeRy tIme Even tHOugh i want tO have the The caCHing enabled for THe entity? I can uSE IsTAtELesssesSion and it woUld wORk in This CAsE beCAuse iT skipS tHE sECond level cache, but is It The recOmmenDed solution?

A:

YOu need to usE cACheMode.IGnorE (WiLL only invalidatE the cAche if updaTEs occur), CAcheMOde.RefreSh (will refRESh all the IteMs iN thE caCHE aNd ignore use_miNIMal_pUtS) or CachEMoDe.Put (wiLl rEfrEsh Any ItEms that arE invalid In ThE cAcHe I Think).  tHe commenTs On tHe EnuMeratIOn valuEs telLs yoU wHaT TheY do a bit BEtTER.
eg:
rEtUrN sesSioN.QUeryOVer<ARTicLeWishLIstItem>()
   .WhEre(A => A.CusToMeRId == custOmerId
 but the query is still ca ched, thro ugh t hesec on d le velcache I assume . 
Myruntime:
.NET 4.0
NHib ernat e: 3.1. 0 .4 000
F luent N H ib e r ant e:  1 .2. 0. 7 12 
My o bje ct:
[Se rializable ]
p ub lic class Ar t ic leWishList Ite m : EntityBa se< int>
{ 
  p ublic  vi rtual  int C u stomer Id { get;  s e t; }
  publi c vi rtua l int ArticleId { ge t ; set; }
    p ublicvi r tu a l  Da teT ime Create dD ate { get; se t ;} }
M y mapping:
pu blic classA rti cleWis hL ist I temMap ping:C las sMap<Articl eWis hListItem >
{
  public Article WishLi stI tem Mapp i ng () 
  { 
    C ach e.ReadWr it e( ).Reg ion( " W i s hLis t") ;

      Id(a => a.I d). Gene r ate dBy.N ative ();
      Map( a =>a. ArticleId).Not. Null able();
     M ap (a => a.Crea ted Dat e).Not. Nullabl e (); 
   Map(a => a.Custo me r I d) .Not.Nul lable( ) ;  }
}

My  q uer y wh e r e res ults ar e cached  contr a ry  t o my wi sh :
   pr iva testati c  Lis t<Arti cleWishL istIt e m> GetArticleW i shListItemsIm p le m e nt a tion (NH ibernate.IS essi o n se ssio n ,int custo merId ) {
        return se ss ion.Qu eryOv er<ArticleWis hListItem> ( )                                .Where( a  => a.Cu stome rId == c ustomerId )                             . List <A rticleW ish ListIte m>( )
                           .ToL i st<Artic le Wis hL ist Item> ( );
   }

W hatis  t h e b est way to m aketh is  que ryhi t the  dat a bas e every  time eve n t h ough  I  w ant tohave the theca ching enab le d f or the e ntity? I  can use IStatelessSess i on anditwould  wor k in this  ca se bec aus e  it sk ips th e sec on d l e v el ca c h e,  bu tis it ther e com mende dsolu tion?
A:

You need to us e  Ca cheMode.Ignor e ( will o nl y i n va l ida te the c ache if updates  occur), C ac h eM ode.Refres h  (w il l refre sh allthe i t ems inthe cache  and igno re  use _ m ini mal_puts)or Cache Mode.Put( willr ef reshany  items  t hat  areinvali d  in  thecacheIthink) .  Th ecomments  on the enumeration val ues te lls y ouwhat they  do a b it better .
eg :
return s ess ion .Quer yOv e r<Art icle W is hLi s tItem >()  .Where( a  = > a . C us tomerId ==c u s tom erId
 but_the query_is still cached, through_the second_level_cache I_assume.
My_runtime:
.NET 4.0
NHibernate: 3.1.0.4000
Fluent_NHiberante: 1.2.0.712
My object:
[Serializable]
public_class ArticleWishListItem : EntityBase<int>
{
_  _public_virtual int CustomerId { get; set; }
    public virtual int ArticleId_{_get; set;_}
__  public virtual DateTime_CreatedDate { get; set; _}
}

My mapping:
public_class ArticleWishListItemMapping : ClassMap<ArticleWishListItem>
{
    public_ArticleWishListItemMapping()
_  _{
        Cache.ReadWrite().Region("WishList");

_     _ Id(a =>_a.Id).GeneratedBy.Native();

__   _  Map(a => a.ArticleId).Not.Nullable();
 _     _Map(a => a.CreatedDate).Not.Nullable();
    _   Map(a => a.CustomerId).Not.Nullable();
_   }
}

My query_where results_are cached contrary to my_wish:
  _ private_static List<ArticleWishListItem> GetArticleWishListItemsImplementation(NHibernate.ISession_session, int customerId)
   _{
  _     return_session.QueryOver<ArticleWishListItem>()
_  ___ _  __ __     __      _   __   _.Where(a => a.CustomerId == customerId)
_     _ _ _          _     _   _ __  _.List<ArticleWishListItem>()
_ _      _ _     _   __     _     _   .ToList<ArticleWishListItem>();
 ___}

What is the best way_to make this query hit the_database every time_even though I want to have the_the_caching enabled for the entity? I_can_use IStatelessSession and it would work_in_this_case because it skips the_second level cache, but is it_the recommended solution?

A:

You need to use CacheMode.Ignore (will only_invalidate the cache_if updates occur), CacheMode.Refresh (will_refresh_all_the items in the cache and ignore use_minimal_puts) or CacheMode.Put_(will refresh_any items that_are invalid in the cache I think).  The comments_on the enumeration values tells you what_they do a bit better.
eg:
return session.QueryOver<ArticleWishListItem>()
   .Where(a => a.CustomerId_== customerId