Hello,
First of all, thanks for this truly impressive product!
Now, over to a problem which I tried to overcome most of yesterday..
I have a table-per-class hierarchy mapping with a superclass and a subclass.
In addition I have a third table/class which I want to associate to the subclass. It looks like this:
Code:
TABLE1 --+--> SuperClass (has property "assocKey")
|
+--> SubClass
TABLE2 -----> OtherClass
<many-to-one>
class="SubClass"
property-ref="assocKey"
The reason I'm using property-ref is that assocKey is not the
primary key of SuperClass.
When loading the mapping into Hibern8 IDE I get the following
errormessage:
net.sf.hibernate.MappingException: property-ref not found: assocKey in class: SubClass
So, it almost looks like SubClass doesn't inherit the property assocKey
from SuperClass. I have also tried to add assocKey to SubClass (which doesn't make sense, and instead I got another errormessage).
The generated SubClass (from the hbm.xml file) do extend
SuperClass
More detailed mapping follows:
SuperClass and SubClass mapping:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<hibernate-mapping>
<class name="SuperClass"
table="TABLE1"
>
<id
name="id"
</id>
<discriminator column="DISCR_COL" type="java.lang.String"/>
<property
name="assocKey"
column="ASSOCKEY"
type="java.lang.String"
length="19"
/>
<!-- subclasses -->
<subclass name="SubClass"
discriminator-value="contractor">
</subclass>
</class>
</hibernate-mapping>
OTHERCLASS mapping:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<hibernate-mapping>
<class name="OtherClass"
table="OTHERTABLE"
>
<id (...)
</id>
<!-- associations -->
<many-to-one
name="subClass"
class="SubClass"
property-ref="assocKey"
unique="true"/>
</class>
Stack trace when loading the mapping:
[java] net.sf.hibernate.MappingException: property-ref not found: assocKey in class: SubClass [java] at net.sf.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:610)
[java] at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:732)
[java] at net.sf.hibern8ide.Hibern8IDE.initialize(Hibern8IDE.java:171)
[java] at net.sf.hibern8ide.Hibern8IDE.reconfig(Hibern8IDE.java:160)
[java] at net.sf.hibern8ide.Hibern8IDE$6.configurationChanged(Hibern8IDE.java:586)
[java] at net.sf.hibern8ide.ConfigurationUI$ApplyConfig.actionPerformed(ConfigurationUI.java:245)
[java] at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1786)
[java] at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1839)
[java] at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
[java] at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
[java] at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:245)
[java] at java.awt.Component.processMouseEvent(Component.java:5100)
[java] at java.awt.Component.processEvent(Component.java:4897)
[java] at java.awt.Container.processEvent(Container.java:1569)
[java] at java.awt.Component.dispatchEventImpl(Component.java:3615)
[java] at java.awt.Container.dispatchEventImpl(Container.java:1627)
[java] at java.awt.Component.dispatchEvent(Component.java:3477)
[java] at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3483)
[java] at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3198)
[java] at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3128)
[java] at java.awt.Container.dispatchEventImpl(Container.java:1613)
[java] at java.awt.Window.dispatchEventImpl(Window.java:1606)
[java] at java.awt.Component.dispatchEvent(Component.java:3477)
[java] at java.awt.EventQueue.dispatchEvent(EventQueue.java:456)
[java] at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
[java] at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
[java] at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
[java] at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
[java] at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)