开发者

Hibernate map declared in abstract class not inherited in subclasses

I have an abstract class A and two classes B and C implementing A.

abstract class A implements Serializable {
  Long id
  String code
  String description
  Map<Locale, String> localizedDescriptions 
}

class B implements A {}

class C implements A {}

With the following hibernate mapping:

<class name="A" abstract="true">

    <id name="id">
        <generator class="org.hibernate.id.enhanced.TableGenerator"/>
    </id>

    <property name="code" unique="true" not-null="true"/>
    <property name="description" not-null="true"/>

    <map 开发者_如何学编程name="localizedDescriptions" lazy="false">
        <key property-ref="code" column="code"/>
        <index column="locale" type="locale"/>
        <element column="description" type="string" not-null="true"/>
    </map>

    <union-subclass name="B"/>
    <union-subclass name="C"/>

The B and C database tables I get have the fields id, code and description as expected. However there are no b_localized_descriptions or c_localized_descriptions tables but there's a a_localized_descriptions table, which isn't what I want. So, is it possible to have the desired behaviour without having to define the map for every subclass ?


<union-subclass name=”C”>
<property name=”salary” column=”SALARY” />
<property name=”bonus” column=”BONUS” />
</union-subclass>

Specify the properties within the union subclass xml tag that you would like included.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜