覆盖休眠子类中的主键

Override primary key in hibernate subclass

我有一个 AbstractAccount hbm 文件,我将 accountNumber 设置为 primarykey。我在我的 Account.hbm.xml 文件中扩展了这个 class,我想在其中覆盖这个主键作为 countryCodeaccountNumber composite key。我该怎么做?

Abstract.hbm.xml 文件。

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
    <class name="com.*.*.*.AbstractAccount" 
    abstract="true" 
    table="ACCOUNT" 
    lazy="false">
        <id name="accountNumber" type="java.lang.String">
            <column name="ACCOUNT_NUMBER" length="16" />
            <generator class="assigned" />
        </id>
       <discriminator column="ACCOUNT_TYPE" type="string"/>
       ................
    </class>
</hibernate-mapping>

Account.hbm.xml

    <property name="modifiedDate" type="java.util.Date">
        <column name="MODIFIED_DATE"/>
    </property>
    <property name="countryCode" type="java.lang.String">
        <column name="COUNTRY_CODE"/>            
    </property>
    ...............
</subclass>   

我试过如下添加复合键,但它不起作用。

<composite-id name="account_country">
<key-property name="countryCode" column="COUNTRY_CODE" />
<key-property name="accountNumber" column="ACCOUNT_NUMBER" />
</composite-id>

Abstract.hbm.xml

<hibernate-mapping>  
    /* Abstract class properites */

     <joined-subclass name="Account" table="tablename">

    /* Account class properites */

     </join-subclass>
</hibernate-mapping>