-->
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: Problems with 1:1/n:1 mapping and inheritence: StackOverflow
PostPosted: Fri Nov 18, 2005 5:49 am 
Beginner
Beginner

Joined: Tue Aug 17, 2004 5:06 am
Posts: 46
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 ?


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.