-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Other side of one-to-many mapping.
PostPosted: Thu Jul 02, 2015 10:38 am 
Newbie

Joined: Thu Jul 02, 2015 10:29 am
Posts: 1
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.