You may take a look on session methods SaveOrUpdateCopy and Merge.
You may take a look on session methods SaveOrUpdateCopy and Merge. Here is an article which gives you more details: Nbernate feature: SaveOrUpdateCopy & Merge.
The URL appears to have changed. It seems to now be codinginstinct. Com/2009/11/… – Richard J Foster Jan 20 '10 at 17:42 Thank you, I've fixed url.
– andrey. Tsykunov Jan 21 '10 at 7:44.
We tried this in a client-server architecture. Now we are moving to DTO (data transfer objects). This means, the detached entities are not directly sent to the client anymore, but specialized objects.
The main reason to move in this direction is not N it is actually the serialization needed to send entities to the client. While you could use lazy-loading (and you will! ) while you are attached to the session, you need to get all references from the database to serialize it.
We had lots of Guids instead of references and lots of properties which are mapped but not serialized ... and it became a pain. So it's much easier to copy the stuff you really want to serialize to its own structure. Besides of that - working detached could work well.Be careful with lazy loading, which will cause exceptions to be thrown when accessing non loaded objects on a detached instance.
Be careful with concurrency, the chance that entities had changed while they where detached is high. Be careful if you need some sort of security or even if you want your server alown to make some data changes. The detached objects could potentially return in any state.
If you look at LLBLGenPro for example: before generating code, you can decide which template you will use. One will use the active record pattern called "self-servicing" and the other one will use the adapter (like the ADO. NET DataAdapter).
The last one is handy when having a disconnected scenario (remoting or webservices). – Patrick Peters Oct 21 '09 at 10:53 1 @Patrick: I have to admit that I don't have a clue what you are talking about. – Stefan Steinegger Oct 21 '09 at 11:55 With the self servicing template LLBLGenPro will create a class (or more) where you can get and set properties (POCO-style) and then call a method like "Save".
This object is self-servicing regarding state management and object-tree loading and SQL creation. The adapter style generates a light-weight class with only properties and is serializable; this object can be passed to an other object that is performing all the state management and SQL creation, etc... – Patrick Peters Oct 21 '09 at 19:02 Ok, but you don't need this when you have NH. So I don't know what you want to tell me with that.
The serialization problem is independent from the database stuff. If you have a complex object graph, where the aggregate root references half of the database. Of course you can serialize half of the database, but usually you don't want to do it.
– Stefan Steinegger Oct 21 '09 at 7:27.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.