first-level-cache

Can first level cache be used with ICriteria or other APIs?

[亡魂溺海] 提交于 2019-12-20 01:10:01
问题 In NHibernate you can easily benefit from first level cache when using Load or Get methods. But what about ICriteria , HQL , Linq-to-NHibernate and QueryOver ? Do they use first level cache too? 回答1: They use it for returning entities, but the queries go straight to the db unless you use the second level cache. Consider this: var fooUsingGet = session.Get<Foo>(fooId); var fooQueryById = session.Query<Foo>().Single(f => f.Id == fooId); Two queries are executed (one for the Get, one for the

Hibernate First level Cache vs Query Cache

自闭症网瘾萝莉.ら 提交于 2019-12-06 08:41:30
问题 Is first level cache different from query cache in hibernate? I have seen articles mentioning about first level and query cache, so i am confused. 回答1: First level cache is enabled by default and is per session basis. Query cache is not enabled by default, is shared across multiple sessions and should always be used in conjunction with the second-level cache. To enable query cache, the following properties should be used: hibernate.cache.use_second_level_cache=true hibernate.cache.use_query

Hibernate First level Cache vs Query Cache

混江龙づ霸主 提交于 2019-12-04 14:08:36
Is first level cache different from query cache in hibernate? I have seen articles mentioning about first level and query cache, so i am confused. First level cache is enabled by default and is per session basis. Query cache is not enabled by default, is shared across multiple sessions and should always be used in conjunction with the second-level cache. To enable query cache, the following properties should be used: hibernate.cache.use_second_level_cache=true hibernate.cache.use_query_cache=org.hibernate.cache.EhCacheProvider hibernate.cache.use_query_cache=true gabrielgiussi Yes, are

Can first level cache be used with ICriteria or other APIs?

◇◆丶佛笑我妖孽 提交于 2019-12-01 18:31:19
In NHibernate you can easily benefit from first level cache when using Load or Get methods. But what about ICriteria , HQL , Linq-to-NHibernate and QueryOver ? Do they use first level cache too? They use it for returning entities, but the queries go straight to the db unless you use the second level cache. Consider this: var fooUsingGet = session.Get<Foo>(fooId); var fooQueryById = session.Query<Foo>().Single(f => f.Id == fooId); Two queries are executed (one for the Get, one for the Query), but both variables contain the same object reference. Now, if you enable the 2nd level cache, query