更新子项时,Hibernate更新父字段

时间:2017-07-24 09:21:28

标签: hibernate parent-child many-to-one

我在Hibernate中定义了以下实体:

YardLotSteering

<hibernate-mapping package="com.volvocars.vcc.cws.e_yardhandlingconfig.commontypes"> 
    <class name="YardLotSteering" table="TWS375"> 
        ...
        <property name="modifiedOn" type="timestamp" access="com.ford.vcc.gent.framework.services.access.TimestampNotNullAccessor"> 
            <column name="CHANGETS"/> 
        </property>  
        <property name="modifiedBy" type="string" access="com.ford.vcc.gent.framework.services.access.StringNotNullAccessor"> 
            <column name="ICDSID"/> 
        </property>  
        <set name="yardSteeringLotCriteriaSet" lazy="true" inverse="true"> 
            <key>
                <column name="NIDTWS375"/> 
            </key>  
            <one-to-many class="com.volvocars.vcc.cws.e_yardhandlingconfig.commontypes.YardSteeringLotCriteria"/> 
        </set>  
    </class> 
</hibernate-mapping>

YardSteeringLotCriteria

<hibernate-mapping package="com.volvocars.vcc.cws.e_yardhandlingconfig.commontypes"> 
    <class name="YardSteeringLotCriteria" table="TWS378"> 
        ...
        <property name="modifiedOn" type="timestamp" access="com.ford.vcc.gent.framework.services.access.TimestampNotNullAccessor"> 
            <column name="CHANGETS"/> 
        </property>  
        <property name="modifiedBy" type="string" access="com.ford.vcc.gent.framework.services.access.StringNotNullAccessor"> 
            <column name="ICDSID"/> 
        </property>  
        <many-to-one name="yardCarComposition" class="com.volvocars.vcc.cws.e_yardhandlingconfig.commontypes.YardCarComposition" column="NIDTWS328" update="false" insert="false" lazy="false"/> 
    </class> 
</hibernate-mapping>

我想要做的是每当更新(插入/更新/删除)子实体时,更新父实体上的modifiedOn和modifiedBy字段。

我已经搜索过这样的其他问题,但从来没有发现任何如此具体的问题。

0 个答案:

没有答案