NHibernate Future<T> with Get()
Asked Answered
S

1

2

How can I use Future for delayed execution with Get() to retrieve a single record (or Load()?)

Also, can I use Future with a detached QueryOver

Stereoscopy answered 15/4, 2011 at 19:20 Comment(0)
V
5

Future with Load does not make any sense, as Load does not go to the DB.

Future with get doesn't make sense either, as Get returns an instance which might already be loaded, in which case it doesn't go to the DB either. The closest you can get to that is a query by id.

In order to get a Future<T> you need an executable query (Criteria/QueryOver/HQL/LINQ). Otherwise, future has no way of resolving it.

Vitascope answered 17/4, 2011 at 2:5 Comment(2)
Future with Get would make a lot of sense. "FutureGet" could return a proxy and when accessing the first, it could load all "future-got" proxies in a single database roundtrip. Without flushing the session and only including the objects which are not in cache yet, which are advantages of Get compared to a query.Trimetrogon
@StefanSteinegger: it would be nice, but Future is not that smart yet. Patches welcome :-)Vitascope

© 2022 - 2024 — McMap. All rights reserved.