1

I have an AbstractAccount hbm file where i set accountNumber as primarykey. I'am extending this class in my Account.hbm.xml file where I want to over ride this primary key as countryCode and accountNumber composite key. How can i do this?

Abstract.hbm.xml file.

<?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>   

I have tried with adding composite key as below, but it is not working.

<composite-id name="account_country">
<key-property name="countryCode" column="COUNTRY_CODE" />
<key-property name="accountNumber" column="ACCOUNT_NUMBER" />
</composite-id>
Vipin CP
  • 3,642
  • 3
  • 33
  • 55

1 Answers1

0

Abstract.hbm.xml

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

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

    /* Account class properites */

     </join-subclass>
</hibernate-mapping>
Vipin CP
  • 3,642
  • 3
  • 33
  • 55
Gokul
  • 931
  • 7
  • 16
  • keep the primary key and some common property same in both class – Gokul Jul 26 '16 at 09:19
  • I can't change the Abstract.hbm.xml file . Its a part of big project and using many where in projects , also its holding by another team. I want to `override` it in `account hbm`, that is the question. Thanks for the reply. – Vipin CP Jul 26 '16 at 09:21