NHibernate does not manually retrieve modified data

Can nHibernate retrieve manually modified data from the repository table? I also disabled the second level cache, but it looks like this (nhibernate) is sometimes fetched from the cache, and sometimes from the repository table.

+3
source share
7 answers

There are two types of caches in nhibernate: session caches and second level caches. A session cache always caches the objects viewed by this session — how nhibernate knows which objects have been modified and which need to be saved. The second level cache that you disabled is below this. The information you see in the cache comes from the session cache.

, (, ), , , . SessionFactory , Session . , - .

, session.Clear() .

+6

NHibernate OO . , , NH.

, "Foo", "Foo" "Id" "SomeProperty". "SomeProperty", "oldValue" "newValue", NH DB, ​​ Foos, SomeProperty = "newValue", DB Foos, . Foo NH "oldValue", Foo ( , 1- ).

NHibernate - StatelessSesion, DB. , NH, NH.

+2

, , :

, ISession.Clear()

, ISessionFactory , , .

, -, SELECT , , , .

+1

, , ; nhibernate, , , , , .

0

Nhibernate - . . Icriterea (nhibernate) . Icriteria:

ICriteria criteria = session.CreateCriteria(typeof (xyzclass));               criteria.Add(Expression.Eq( "xyzclass", somestringto retreivedata));               criteria.SetCacheable();                .UniqueResult();

0

NHibernate , , , , , , .

, : - , ? , , , - , NHibernate, / .

0

.

But in the future, we could manually edit the data. I also set lazy to false for this table and commented on all the second level cache properties used in sleep mode. But even then, it returns me different values ​​instead of the recently changed value. Sometimes it gives me an old meaning, and sometimes a new one, so it is not permanent.

0
source

Source: https://habr.com/ru/post/1697491/


All Articles