开发者

Nhibernate Not Updating Cascade Relation On Win Server 2008

We are using NHibernate with Fluent mapping to build a WebForms application.

In our model, we have a simple References relationship with Cascade.All() set. When we save the entity, NH behaves as expected and 1) saves the referenced 开发者_JAVA技巧entity, 2) updates the parent entity setting the child key.

Deploying this same version to our production server (Win Server 2008) and pointing the application to the same database, though, produces a different output. NH 1) saves the referenced entity and.. and.. that's it, nothing else happens!!

I know that our test and production enviroments should be the same, etc, etc.. but we are deploying right now and I simply can't figure out how this can be happening.

Is there any known issue with NH in Win 2008 Server regarding assembly permissions or something like? Looks like the proxy isn't working properly for some reason, but I really can't tell why!

EDIT 1: Analysing NH log files I could find that NH doesn't note that the referenced property changed in Win Server 2008. Why? No idea, but it looks like more and more a proxy problem.

Any help is really appreciated.

Filipe


I've finally found what was causing the problem. NH wasn't updating the relatioship because it had no transaction covering the statements.

It doesn't look like logical in a first look, but there are other situations where NH only behaves properly if you have a transaction open (e.g.: NHibernate FlushMode Auto Not Flushing Before Find). We've had this situation in another projects and the theory fits.

But what about Windows Server 2008? Actually, the problem was in our web.config file with IIS 7. As we use an automatic transaction control with an OpenSessionInView design, we register an httpModules item. But in IIS 7 we have to register a modules item, and we didn't have it. As it wasn't configured, we had no transaction, and with no transaction things doesn't work.

Lesson learned #1: more then ever, transactions are a MUST when using NHibernate. Lesson learned #2: never disable IIS compatibility messages (why someone did that?).

Filipe

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜