1
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC  "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-   mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.business.Test" table="Test">
    <composite-id name="key">
        <key-property name="x" column="X"/>
        <key-property name="y" column="Y"/>
    </composite-id>

    <set name="valueObjects" inverse="false" lazy="false" cascade="all">
        <key>
            <column name="X"/>
            <column name="Y"/>          
        </key>
        <one-to-many class="com.business.ValueObjects" />
    </set>

</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>
<class name="com.business.ValueObjects" table="ValueObjects" mutable="false">
    <id name="id" type="java.lang.Long" column="ID">
      <generator class="sequence">
          <param name="sequence">ID_SEQ</param>
      </generator>
    </id>

    <property name="x" column="X"/>
    <property name="y" column="Y"/>

</class>
</hibernate-mapping>

When i load the Test object, hibernate loads the ValueObjects collections. But when i update the ValueObjects and save Test. I dont see any insert or Update statements.

PLease suggest what to do.

Raulito

4

1 回答 1

2

在 hibernate 中,'<strong>mutable' 在及其相关集合中默认为 '<strong>true',表示类或集合允许添加、更新和删除。另一方面,如果将mutable更改为 false,则它在类及其相关集合中具有不同的含义。所以你需要删除mutable属性并将inverse属性设置为true

于 2013-02-21T08:04:57.117 回答