Hi,
I am trying to create a new database where each entity is versioned. This means that I have an id(catalog number) for each entity that is constant over time. I also have an id for each version (serial number). Each version has two dates corresponding to validfrom/validto of that particular version. Each association between entities is hooked up by a foreign key reference to catalog number.
The application usage is to query all data that is valid at a particular point in time.
From an application writer point of view, I would like to use 1:1,1:N,N:1 to map all the relationships. It is just cleaner that way.
I took a look at filters and read many posts talking about why they don't/shouldn't correspond to the cardinality of an association. I don't necessarily disagree, but unfortunately it doesn't help solve this problem.
I took a look at the version column but that basically only seems used for concurrency purposes and doesn't really address query for particular versions.
Is there some way to parameterize some property across a graph query so that I can retrieve a snapshot of the object graph at a specified time?
I can think of several hard-coded ways to do this (like creating a mapping/view to the db with fixed points in time), but none of them seem to be the correct solution and effectively mean operational changes to keep the mappings/views up-to-date.
This problem is relevant for a new system I'm writing as well as reading data from a legacy system.
Here is a mapping file for two entities of the legacy system:
Code:
<hibernate-mapping default-access="field" package="com.ubs.eqdel.data.model.instance">
<class name="Factor">
<id name="id">
<generator class="native"/>
</id>
<property name="catalog" column="catalog#"/>
<property name="vol"/>
<property name="factorIdentity"/>
<property name="currency"/>
<property name="size"/>
<property name="validfrom_date"/>
<property name="termination_date"/>
<bag name="betas" mutable="false">
<key column="factorID" property-ref="catalog"/>
<one-to-many class="Beta"/>
<filter name="validAtFilter"/>
</bag>
<filter name="validAtFilter"/>
</class>
<class name="Beta">
<id name="id">
<generator class="native"/>
</id>
<property name="catalog" column="catalog#"/>
<property name="product"/>
<property name="beta"/>
<property name="validfrom_date"/>
<property name="termination_date"/>
<!--
<many-to-one name="factor" column="factorID" property-ref="catalog"/>
-->
<filter name="validAtFilter"/>
</class>
<filter-def name="validAtFilter" condition="validfrom_date <= :validAtDate AND termination_date > :validAtDate">
<filter-param name="validAtDate" type="timestamp"/>
</filter-def>
</hibernate-mapping>
The above is an example where I tried using filters(notice how I had to disable the many-to-one because of the cardinality problems). I don't really care what the mechanism is, but some type of query-scoped parameterization seems like the right approach.
I'm using Hibernate version 3.1.
Any help would be appreciated.
Thanks,
Dave
[/code]