views:

14

answers:

0

Hello everybody,

I am having a Problem with my nhibernate-mapping and I can't find a solution by searching on stackoverflow/google/documentation.

The database I am using has (amongst others) two tables. One is unit with the following fields:

  • id
  • enduring_id
  • starts
  • ends
  • damage_enduring_id
  • [...]

The other one is damage, which has the following fields:

  • id
  • enduring_id
  • starts
  • ends
  • [...]

The units are assigned to a damage and one damage can have zero, one or more units working on it. Every time a unit moves to annother damage, the dataset is copied. The field "ends" of the old record and "starts" of the new record are set to the current time stamp, enduring_id stays the same. So if I want to know which units were working on a damage at a certain time, I do the following select:

select * from unit join damage on damage.enduring_id = unit.damage_enduring_id where unit.starts <= 'time' and unit.ends >= 'time'

(This is not an actualy query from the database, I made it up to make clear what I mean. The the real database is a little more complex)

Now I want to map it that way, so I can load all the damages which are valid at one time (starts <= wanted time <= ends) and that each of them has a Bag with all the attached units at that time (again starts <= wanted time <= ends).

Is this possible within the mapping?

Sorry if this is a stupid question, but I am pretty new to nhibernate and I have no clue how to do it.

Thanks a lot for reading my post!

Bye, Tobias