I have a database with a field value that is not a foreign key into another table directly, but whose value can be computed into such a key. Initially, I loaded a field "project" from a batch jobs table as:
<property name="project" column="CMD" type="BSApp.BSProject" insert="false" update="false" unique="false" />
where "project" was computed from the command given to a batch queue "jobs" table. The batch system has no notion of PROJECT, but my app can determine it from the command string value.
Now, I have a "PROJECTS" class and am trying to establish a many-to-one relationship between projects and jobs; that is, each job refers to at most one project, but a project can be associated with many jobs. However, the project is 'computed' from the CMD. That is, I am trying to do "effectively"
<many-to-one name="project" column="CMD" entity-name="project" type="BSApp.BSProject"/>
(with the reverse relationship
<set name="jobs" inverse="true"> <key column="CMD"/> <one-to-many entity-name="job" type="BSApp.BSProject"/> </set> in my PROJECTS table).
But MANY-TO-ONE and ONE-TO-MANY do not accept the "type" attribute.
Is there a way for many-to-one and one-to-many to map through a custom datatype method similar to the one used by "property"?
Thank you, JKE
|