0
votes

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 derive 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?

2

2 Answers

1
votes

This would best be accomplished using a PostLoadEventListener.

0
votes

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