开发者

NHibernate many-to-one by formula?

开发者 https://www.devze.com 2023-01-24 12:05 出处:网络
I\'m using NHibernate 2.1.2, and would like to load a many-to-one association using a formula. Given an arbitrary domain entity E[X], there is a calculation to deriv开发者_如何学JAVAe the primary key

I'm using NHibernate 2.1.2, and would like to load a many-to-one association using a formula.

Given an arbitrary domain entity E[X], there is a calculation to deriv开发者_如何学JAVAe the primary key of the previous entity E[X-1]. I'd like each entity to be loaded as a node in a linked list, with each entity having a "Previous" property which is loaded lazily using this formula, so I can traverse the history if I like.

In other words, no direct reference to the previous entry is stored in the current entry, but a formula is available to compute the previous key.

I've tried to specify "formula" for a many-to-one, but of course it fails with "property mapping has wrong number of columns". Any other suggestions for achieving this goal?


This would best be accomplished using a PostLoadEventListener.


The problem was a bug in the NHibernate 2.x series. I upgraded to the NHibernate 3.0 beta, and the problems were resolved.

0

精彩评论

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