Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: 2.1.6
Mapping documents:
<class name="Flight">
<id name="oid" type="java.lang.Long">
<generator class="native"/>
</id>
<discriminator column="direction" length="1"/>
<one-to-one name="rotation" class="Rotation" cascade="none"/>
<subclass name="IncomingFlight" discriminator-value="I">
<property name="divertedDateTime" type="java.util.Date" not-null="false"/>
<property name="heldDateTime" type="java.util.Date" not-null="false"/>
</subclass>
<subclass name="OutgoingFlight" discriminator-value="O">
</subclass>
</class>
<class name="Rotation">
<id name="oid" type="java.lang.Long">
<generator class="native"/>
</id>
<!-- many to one -->
<many-to-one name="incomingFlight" class="Flight" column="FK_INC_FLIGHT" cascade="save-update" unique="true"/>
<many-to-one name="outgoingFlight" class="Flight" column="FK_DEP_FLIGHT" cascade="save-update" unique="true"/>
</class>
Name and version of the database you are using: Oracle 9i, thin driver
Debug level Hibernate log excerpt:
2005-11-18 10:33:23,903 INFO net.sf.hibernate.cfg.SettingsFactory - Optimize cache for minimal puts: false
2005-11-18 10:33:23,903 INFO net.sf.hibernate.cfg.SettingsFactory - echoing all SQL to stdout
2005-11-18 10:33:23,903 INFO net.sf.hibernate.cfg.SettingsFactory - Query language substitutions: {true=1, false=0}
2005-11-18 10:33:23,903 INFO net.sf.hibernate.cfg.SettingsFactory - cache provider: net.sf.hibernate.cache.EhCacheProvider
2005-11-18 10:33:23,903 INFO net.sf.hibernate.cfg.Configuration - instantiating and configuring caches
2005-11-18 10:33:23,903 INFO net.sf.hibernate.impl.SessionFactoryImpl - building session factory
2005-11-18 10:33:55,263 INFO net.sf.hibernate.util.ReflectHelper - reflection optimizer disabled for: at.vie.flightbean.bo.OutgoingFlight, StackOverflowError: null
2005-11-18 10:34:05,856 INFO net.sf.hibernate.util.ReflectHelper - reflection optimizer disabled for: at.vie.flightbean.bo.IncomingFlight, StackOverflowError: null
We have the following classes:
* Flight
* IncomingFlight extends Flight
* OugoingFlight extends Flight
* Rotation
A Rotation has two 1:1 relations: incomingFlight, outgoingFlight
A Flight has a 1:1 relation: rotation
We modeled this in the following way:
Flight 1:1 -> Rotation
Rotation n:1 -> IncomingFlight
Rotation n:1 -> OutgoingFlight
So the Rotation has two foreign key columns for the OIDs of the associated flights.
Unfortunately this doesn't seem to work. When Hibernate initializes it's session factory we get a StackOverflowError (see the log above).
A problem might be that we have two n:1 relationships to the same class, which is part of an inheritence hierarchy, so in fact this is a polymorphic n:1 relationship.
Any hints or workarounds ?