Hi everyone,
Recently i've also faced similar problem. First i've posted a <a
href="http://groups.google.com/group/castle-project-users/
browse_thread/thread/f2fc359da7228fca?hl=en"> question</a>  to
castleproject-users group, but than after deeper investigation it
turned out to be the NHibernate behavior.
I'm working in the web context, so my scenario is the following:
1. Get entity from repository by Id
2. Bind simple properties (like string, integers etc.)
3. Bind Many-to-one properties (like User.Country)
4. If binded entity is valid - persist changes, otherwise show
validation erros and DO NOT SAVE invalid dirty entity.

With default auto-flushing dirty objects behavior i get the following
problems:
1. During the step3 i have to query database to get entities
references as many-to-one. Sometimes Session.Load is not suitable and
i have to query database, that causes unwanted flushing.
2. During validation i also might need to query database (to check
Unique constraints), than also causes unwanted flushing.

Currently i see few possible ways, but they are not brilliant:
1. Use FlushMode.Commit. The disadvantage here is that during
executing select statements the result won't be relevant, because
valid not flushed changes to the entities won't be taken into account.
2. Forget about persistence ignorance and use evict and attach to
session approach within business logic code
3. First bind to in-memory DTO, check if data is valid and only then
map changes to the real entity. But this approach will produce a lot
of extra code and bugs.

If there are no other ways i'm going to choose manual Evicting.
Am i missing something?
Thanks for your help
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to nhusers@googlegroups.com
To unsubscribe from this group, send email to 
nhusers+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to