Search code examples
xmlhibernatehibernate-mapping

What am I missing in this mapping of hbm file?


I have been getting this error after I plugged my hbm to hibernate. As referenced by multiple questions from here, I seem not to find the correct answer as I seem to have laid out my hbm well.

Error parsing XML (2) : The content of element type "class" must match "(meta*,subselect?,cache?,synchronize*,comment?,tuplizer*,(id|composite-id),discriminator?,natural-id?,(version|timestamp)?,(property|many-to-one|one-to-one|component|dynamic-component|properties|any|map|set|list|bag|idbag|array|primitive-array)*,((join*,subclass*)|joined-subclass*|union-subclass*),loader?,sql-insert?,sql-update?,sql-delete?,filter*,fetch-profile*,resultset*,(query|sql-query)*).

This is my whole hbm file which might help

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
    <class name="com.ccti.citrine.model.THMT940" table="TBL_TH_MT940">
        <id name="id">
            <column name="ID" length="32" not-null="true"></column>
            <generator class="uuid.hex"></generator>
        </id>
        <property name="del" type="java.lang.Integer">
            <column name="DEL" />
        </property>
        <version name="version" type="java.lang.Integer">
            <column name="VERSION" not-null="true" />
        </version>
        <many-to-one name="corporation" class="com.ccti.citrine.model.Corporation" fetch="select" insert="false" update="false" lazy="false">
            <column name="CORP_ID"/>
        </many-to-one>
        <property name = "corpId" type ="java.lang.String">
            <column name = "CORP_ID"/>
        </property>
        <property name = "accountNo" type ="java.lang.String">
            <column name = "ACCT_NO" length = "32"/>
        </property>
        <many-to-one name="currency" class="com.ccti.citrine.model.Currency" fetch="select" insert="false" update="false" property-ref="cd" lazy="false">
            <column name="CURRENCY_CD"/>
        </many-to-one>
        <property name = "currCd" type ="java.lang.String">
            <column name = "CURRENCY_CD" length = "10"/>
        </property>
        <property name="availableBalance" type="java.math.BigDecimal">
            <column name="AVAIL_BAL" />
        </property>
        <property name="withdrawBalance" type="java.math.BigDecimal">
            <column name="WITHDRAW_BAL" />
        </property>
        <property name="txnValueDate" type="java.util.Date">
            <column name="TXN_VAL_DT" />
        </property>
        <property name="createdDt" type="java.util.Date">
            <column name="CREATED_DT" />
        </property>
        <property name="netBegBalance" type="java.math.BigDecimal">
            <column name="NET_BEG_BAL" />
        </property>
        <property name="floatAmt1" type="java.math.BigDecimal">
            <column name="FLOAT_AMT_1" />
        </property>
        <property name="floatAmt2" type="java.math.BigDecimal">
            <column name="FLOAT_AMT_2" />
        </property>
        <property name="floatAmt3" type="java.math.BigDecimal">
            <column name="FLOAT_AMT_3" />
        </property>
    </class>

Solution

  • This helped. As I was trying to follow the order of the table in the database, I have known that <property> should always come last nevertheless. As projected above, <version> came first after the property, Del.

    Given this table, I have overlooked that Del is indeed a property and it should have come after the discriminator - version.

    enter image description here