Hello everyone,
I'm working on a legacy project and need help with NHibernate mapping.
Here's the situation:
Class A in table_1 has a referenced_id (Guid).
Class B in table_2 has version_id (Guid, pk), id (Guid), and valid_from
(DateTime).
Business Logic: At any given time, there is exactly one valid version of
Class B with a specific id.
Goal: Map Class A to Class B using a user-provided timestamp to find the
correct version at runtime.
Current Attempt:
<set name="Class_B" table="my_new_mapping_table" cascade="none"
lazy="false" fetch="join" batch-size="100">
<key column="..." />
<many-to-many class="Class B"
column="referenced_id"
property-ref="id"
fetch="join"
lazy="false"
unique="true" />
<filter name="filter"
condition="valid_from in (select max(b.valid_from) from table_2 b where
:timestamp >= b.valid_from and b.id = referenced_id)" />
</set>
The set will never have more than one entry, creating unnecessary overhead.
I am not sure if I can use a different mapping since the filter is not
possible and I can't figure out if the 'formula' option allows for runtime
user input.
I'm looking for alternative approaches to achieve this mapping efficiently.
Any suggestions would be greatly appreciated.
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/nhusers/74803512-4de6-4694-af0c-fdfbece3d72an%40googlegroups.com.