/Oskar
> --
> You received this message because you are subscribed to the Google Groups "nhusers" group.
> To post to this group, send email to nhu...@googlegroups.com.
> To unsubscribe from this group, send email to nhusers+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.
>
I understand the point of Ayende's article to mainly concern
performance. If you know the primary key, the fastest way is
Get()/Load(), and you should use them unless there is a good reason
not to.
Using a query method will bypass the cache and always execute in the
database. However, using automatic flush mode, NH can automatically
insert the row for the newly saved object when the same table is hit
by the query.
/Oskar
Hi,We are using Automatic flush mode, but it is very explicitly and precisely not flushing when we query. The code example I posted in my previous post is factually correct, the second line (i.e. query) will/does throw an exception.Cannot viably use Get()/Load() because the Query is composed further up the chain, thus the Law of Demeter kicks in and well.. it's pretty ugly for the domain to know what is and isn't a concern of the DB anyway. :)Though I must ask.. why implement a Cache if it is not going to be Queryable?Regards,John.
The L1 cache is more like the "working data set" - it contains the
objects currently tracked by the session. This has multiple purposes:
avoiding object duplication, knowing which objects to persist when
flushing changes, and performance. NH relies on the database to
execute queries, returned objects may still come from the L1 cache if
they were already loaded.
Regarding the oversimplified code example you gave, have you executed
that code exactly as written?
/Oskar
--
You received this message because you are subscribed to the Google Groups "nhusers" group.
To view this discussion on the web visit https://groups.google.com/d/msg/nhusers/-/uraL59S5BY8J.
You may need an explicit transaction (BeginTransaction) for autoflushing to work as expected.
/G
2012/4/10 John T
Hi,
To view this discussion on the web visit https://groups.google.com/d/msg/nhusers/-/jZYrwqvtmT0J.
Yes, I believe it is.
/G
2012/4/10 John TIs this necessary within a TransactionScope?