Question

NHibernate with the Unit of Work pattern is best suitable for HTTP solutions but my server has permanent connected users and it's efficient to keep all their data in the memory.

With session-detached objects I can't use lazy loading and many NHibernate features also expects me to use the Unit of Work pattern.

Does NHibernate offer any good solutions to work with session-detached objects?

Merge is not good enough here because it's the same redundant data loading (even from cache). Or should I use other solutions instead of NHibernate for this kind of server? Any good ORMs?

Was it helpful?

Solution

You can attach to the session the detached object, see http://rmfusion.com/open_source/nhibernate/nhibernate_net_object_persistence.htm

here said

by reattaching the object to a new Persistent Manager (ISession). The object state will then be synchronized with the database again, at the end of the transaction.

There are other orm such entity framework, but depend of course of the architecture, in general, for a game, you should load from database, use in cache , and in a few events, update the database. Is not a good idea stay connected, and trying to synchronize all the time .

Also, I recommend you if the lazy loading doesn't seems to work for you, review the database, review the schema, and thing first in the DB than the model. (Thinking in performance) maybe you can normalize-denormalize tables

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top