I have a class called A which has set of object of B. On inserting the A all the objects in the set must be inserted. But in my case only the object A is inserting not the sets.
请注意,B 类也有在某些情况下可能为空的对象集合。关系:第 1 页---->* 类 Page.hbm.xml
<hibernate-mapping>
<class catalog="uml" name="com.project.lwuml.classdiagram.entity.Page" table="page">
<id name="id" type="java.lang.Integer">
<column name="id"/>
<generator class="identity"/>
</id>
<property name="content" type="string">
<column length="65535" name="content"/>
</property>
<set inverse="true" name="classboxes" table="classbox" lazy="true" fetch="select">
<key>
<column name="page_id" not-null="true"/>
</key>
<one-to-many class="com.project.lwuml.classdiagram.entity.Classbox"/>
</set>
</class>
</hibernate-mapping>
Classboxes.hbm.xml
<hibernate-mapping>
<class catalog="uml" name="com.project.lwuml.classdiagram.entity.Classbox" table="classbox">
<id name="id" type="java.lang.Integer">
<column name="id"/>
<generator class="identity"/>
</id>
<many-to-one class="com.project.lwuml.classdiagram.entity.Accessspecifiers" fetch="select" name="accessspecifiers">
<column name="accessspecifiers_id" not-null="true"/>
</many-to-one>
<many-to-one class="com.project.lwuml.classdiagram.entity.Page" fetch="select" name="page">
<column name="page_id" not-null="true"/>
</many-to-one>
<property name="className" type="string">
<column length="128" name="className"/>
</property>
<set inverse="true" lazy="true" name="classmethods">
<key>
<column name="classbox_id" not-null="true"/>
</key>
<one-to-many class="com.project.lwuml.classdiagram.entity.Classmethod"/>
</set>
<set inverse="true" name="classdatamembers">
<key>
<column name="classbox_id" not-null="true"/>
</key>
<one-to-many class="com.project.lwuml.classdiagram.entity.Classdatamember"/>
</set>
</class>
</hibernate-mapping>
我正在使用 struts-spring-hibernate。任何机构都可以帮助我。提前致谢