Hi there guys, this is my first post and I'm trying to figure out why my understanding of how mappings
work in Hibernate is wrong.
I have a SensorDescription, a SensorInstance and a Probe.
A probe has many SensorInstances.
Those SensorInstances are all described by a SensorDescription.
So my understanding was:
I create a bidirectional mapping with SensorDescription and Probe being an owner.
For SensorInstance I have a separate DB table which holds foreign keys to the SensorDescription
and Probe.
This is how it looks like (snippets):
Code:
<class name="Probe" table="probes">
[...]
<bag name="sensorInstances" table="sensor_instances">
<key column="probe_id" not-null="true" />
<one-to-many class="SensorInstance" />
</bag>
</class>
<class name="SensorDescription" table="sensor_descriptions"
[...]
<bag name="sensorInstances" table="sensor_instances">
<key column="sensor_description_id" not-null="true" />
<one-to-many class="SensorInstance" />
</bag>
</class>
<class name="SensorInstance">
[...]
<many-to-one name="sensorDescription" class="SensorDescription">
<column name="sensor_description_id" />
</many-to-one>
[...]
</class>
However after configuration Hibernate tells me that the "sensor_description_id" column
cannot be mapped twice and I have to use insert="false" update="false" (on which one
anyway?).
The obvious way to fix the error is to add these but I'm not sure if that's what I want.
Am I misunderstanding things here?
Thanks for your time.
I'm also on IRC in Freenode right now, if you'd prefer chatting.