Hi,

At the moment I'm building the base architecture for a web application
which uses NHibernate as it's data access layer. I'm are using
LinFu.Dynamic
Proxy to create runtime-proxies for our entities to achieve certain
additional functionalities like:

- Implementation of Policies
- Authorization
- Logging/Tracing
- ... (other cross cutting concerns)

This all works fine, but - and now to the problem I have with
NHibernate -
NHibernate ist not workling properly with those proxies. To avoid
errors like "no persister for: UserProxy" my repositories also make
use
of proxies to intercept calls to methods like "SaveOrUpdate" where
I unwrap the entity from my own proxies an then delegate those
"original" entities to NHibernate, and on the way back wrap results
from the repositories into proxy instances.

This worked fine until I tried to use "SaveOrUpdate". The error I got
was "NonUniqueObjectException: a different object with the same
identifier value was already associated with the session".

The first thing I tried was to disable the whole proxy-infrstructure.
After that the error I mentioned above did no longer appear. That
was the point where some hours of googleing and blog-reading
lead to no result.

My last attempt was to create a custom Persister which should
be able to deal with my proxy type. But unfortunately with no
positive result. I was able to implement a custom Persister, but
at (Fluent)NHibernate configuration time a error occured which
tells me that the assembly file "ProxyAssembly" was not found, which
is not very surprising since the LinFu proxy types are located
in an in-memory assembly.

Now I have to admit: I'm totally stuck and out of ideas. ;-)
Maybe somewone has an idea to convince NHibernate to persist
dynamic proxies or use the unproxied instances. This ist the most
odd thing: why is NHibernate complaining about non-uniqueness
only if the unproxied instances are used? I tried to evict and re-
merge
those entities, what lead to a partial success. I could
"SaveOrUpdate"
the instances, but only bevor a first "CommitTransaction" within one
transaction and not in another transaction or after an "Flush".

I hope someone can help a bit, or enlighten me with some other view
or inside-knowlege of NHibernate.

I'd be pleased to hear some ideas on this very tricky topic.

Kind regards, Matthias

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to