0

私はうまくいくと信じている複雑なマッピングを持っています。しかし、コンパイル後にクラスの Ad 列が存在しないように見えるのはなぜでしょうか?

public abstract Class A {
private Integer Id;
..
...
}

public Class SubA extend A {
   private D d;
}

public Class D {
   private SubA subA;
}

A.hbm.xml
<class name="A" table="A" abstract="true"/>

...

<subclass 
        name="SubA" 
        discriminator-value="SUB_A"
        lazy="false"
    >
        <join table="TABLE_SUB_A">
                <key column="ID"/>

            <many-to-one name="d" 
        column="COL_D" 
                class="D"
                cascade="NONE"
                outer-join="true"
                unique="true"/>
        </join>
   </subclass>
   </class>

D.hbm.xml
<one-to-one name="subA"
   class="SubA"
   property-ref="d"/>
4

1 に答える 1

0

Your code doesn't show discriminator column definition in A class, I'm assuming it's there. Also there's no "outer-join" attribute; it should be fetch="outer-join" instead.

Other then that, though, it looks OK - d property should be looked up on subA, not A. Are you sure you haven't changed anything when you've posted (I don't think you real entities are called A and D, so double check that you mapping is indeed as shown).

Also, why are you using discriminator for table-per-subclass? Using joined-subclass makes for easier mapping with no superfluous columns; the only advantage of discriminator is avoiding outer join on subclass tables which is usually not a big deal (plus you haven't specified fetch="select" on your subclass anyway)

于 2009-11-06T01:46:43.870 に答える