I tried you suggestion, in the following composite-id form:

        <composite-id name="id" 
            class="org.appfuse.persistence.ChildId" unsaved-value="none">

            <key-property column="record_num" length="22" name="recordNum"
type="long"/>
            <key-many-to-one name="parentId" class="java.lang.Long"
column="parent_id" />
        </composite-id>

And now I get:

    [junit] org.appfuse.persistence.DAOException:
cirrus.hibernate.MappingException: An association
refers to an unmapped class: java.lang.Long

So I thought, "hmmm, maybe the class should be my parent" - and I tried
that:

<key-many-to-one name="parentId" class="org.appfuse.persistence.Parent"
column="parent_id" />

and I got:

    [junit] org.appfuse.persistence.DAOException:
cirrus.hibernate.PropertyAccessException: IllegalA
rgumentException occurred while calling setter of
org.appfuse.persistence.ChildId.parentId

Any ideas are appreciated.

Matt


> -----Original Message-----
> From: jiesheng zhang [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, February 05, 2003 12:59 AM
> To: '[EMAIL PROTECTED]'
> Subject: Re: [Hibernate] Parent / Child Mapping with composite-id
> 
> 
> > <hibernate-mapping>
> >     <class name="org.appfuse.persistence.Child"
> > table="child">
> >         <composite-id name="id" 
> >             class="org.appfuse.persistence.ChildId"
> > unsaved-value="none">
> >             <key-property column="parent_id"
> > length="22" name="parentId"
> > type="long"/>
> Try this:
> <key-many-to-one name="parent" column="parent_id"
> type="long" cascade="none"/>
> and remove the the <many-to-one> below.
> 
> 
> 
> 
> 
> >             <key-property column="record_num"
> > length="22" name="recordNum"
> > type="long"/>
> >         </composite-id>
> >         <property column="name" length="30"
> > name="name" type="string"/>
> >         <property column="description" length="100"
> > name="description"
> > type="string"/>
> >         <many-to-one name="parent"
> > column="parent_id" not-null="true"/>
> >     </class>
> > </hibernate-mapping>
> > 
> > I get:
> > 
> >     [junit] java.sql.BatchUpdateException: General
> > error: Column 'parent_id'
> > specified twice
> > 
> > 
> > To make it work, I've specified readonly="true" on
> > the parent's mapping, and
> > explicity saved the child objects.  This seems to be
> > the desired path for
> > using Hibernate?  Am I correct?
> > 
> > Parent's mapping:
> > 
> >         <bag role="children" table="child"
> > readonly="true" cascade="all">
> >             <key column="parent_id" length="22" />
> >             <one-to-many
> > class="org.appfuse.persistence.Child"/>
> >         </bag>
> > 
> > In order to update properly:
> > 
> >             Iterator it =
> > p.getChildren().iterator();
> > 
> >             while (it.hasNext()) {
> >                 Child c = (Child) it.next();
> >                 ses.update(c);
> >             }
> > 
> >             ses.update(p);
> >             ses.flush();
> > 
> > Thanks,
> > 
> > Matt
> > 
> > 
> > 
> >
> -------------------------------------------------------
> > 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
> 
> 
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
> http://mailplus.yahoo.com
> 
> 
> -------------------------------------------------------
> 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
> 



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