hibernate composite key mapping 問題

<hibernate-mapping package="abc">
        <class name="Parent" table="parents">
                <id name="id" column="id">
                        <generator class="native" />
                </id>
                ................
                <map name="childs" table="childs">
                        <key column="parent_id" />
                        <map-key-many-to-many column="index_id"
                                class="Index" />
                                <one-to-many class="Child" />
        </class>
</hibernate-mapping>


<?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 package="abc">
  <class name="Child" table="childs">
          <composite-id>
                  <key-many-to-one name="index" class="Index" column="index_id" />
                  <key-many-to-one name="parent" class="Parent" column="parent_id" />
          </composite-id>
           -->
           <composite-id>
        <key-property name="languageId" column="language_id" access="field" />
        <key-property name="promotionId" column="promotion_id" access="field" />
    </composite-id>
   ............................
  </class>
</hibernate-mapping>

public class Parent() {
Map<Index, Child> childs = new HashMap<Index, Child>();

public void addChild(Index index, Child child) {
this.childs.put(index, child);
}
}

但是 insert / update / delete child 的動作不能反映在 db

我未用過 composite key,
你有冇 commit ?

TOP