I have made progress saving my collections (thanks to Gavin), and I am
down to my last bug, I think. Here is what is happening:

1) I create an new parent class
2) I create a new child class
3) I add the child record to the parent class's set
4) I save the parent record

At this point hibernate first tries to save the child record, but it
does not yet get the sequence for the parent record so it tries to
insert NULL into the key column for the parent record and the DB is
throwing a SQL error. Any ideas?

Here are my mapping files:


  PARENT
------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD
1.1//EN" 
"http://hibernate.sourceforge.net/hibernate-mapping-1.1.dtd";>
<hibernate-mapping>

    <class name="com.notiva.entity.submatch.SubMatch" table="SUB_MATCH">
        <id name="id" type="java.lang.Long" unsaved-value="null">
            <column name="SUB_MATCH_ID" />
            <generator class="sequence">
                <param>SEQ_SUB_MATCH_ID</param>
            </generator>
        </id>

        <property column="MATCH_ID" length="10" name="matchId"
not-null="true" type="java.lang.Long"/>
        <property column="MATCH_LEVEL_ID" length="10"
name="matchLevelId" not-null="true" type="java.lang.Long"/>
        <property column="REASON_CODE_ID" length="10"
name="reasonCodeId" type="java.lang.Long"/>
        <property column="VARIANCE_AMT" length="18" name="varianceAmt"
not-null="true" type="java.lang.Double"/>
        <property column="DISPUTE_AMT" length="18" name="disputeAmt"
type="java.lang.Double"/>
        <property column="ADJUSTMENT_DESC_TXT" length="100"
name="adjustmentDescTxt" type="java.lang.String"/>

        <set role="invoices" table="SUB_MATCH_INVOICE" readonly="false"
cascade="all">
            <key column="SUB_MATCH_ID" />
            <one-to-many
class="com.notiva.entity.submatch.SubMatchInvoice"/>
        </set>

    </class>
</hibernate-mapping>


  CHILD
---------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD
1.1//EN" 
"http://hibernate.sourceforge.net/hibernate-mapping-1.1.dtd";>
<hibernate-mapping>
    <class name="com.notiva.entity.submatch.SubMatchInvoice"
table="SUB_MATCH_INVOICE">

        <id  name="id" type="java.lang.Long" unsaved-value="null">
            <column name="SUB_MATCH_INVOICE_ID"/>
            <generator class="sequence">
                <param>SEQ_INVOICE_ID</param>
            </generator>
        </id>

        <property column="INVOICE_ID" length="10" name="invoiceId"
not-null="true" type="java.lang.Long"/>
        <property column="CREATE_TS" length="11" name="createTs"
not-null="true" type="timestamp"/>
        <property column="CREATE_USER_TXT" length="40"
name="createUserTxt" not-null="true" type="java.lang.String"/>

        <many-to-one name="subMatchId" column="SUB_MATCH_ID"
class="com.notiva.entity.submatch.SubMatch"
            cascade="all" unique="true" not-null="true"
outer-join="true" />

    </class>
</hibernate-mapping>

Thanks,

Matt Dowell
Notiva Corp


-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
_______________________________________________
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel

Reply via email to