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