我想使用DelegatingReverseEngineeringStrategy生成pojos和hbm文件。我能够自定义诸如实现接口,toString方法,对所有表对象的渴望获取等。使用DelegatingReverseEngineeringStrategy休眠逆向工程
不过,我需要定制两个特点:
考虑两个表中父母与子女,其中有一个父母与子女之间的多对多关系。
我想:
组反=“假”在父HBM子集合
一套级联=“全”在父HBM子集,这样如果我更新家长收集它应该将效果级联到儿童收集。
<hibernate-mapping> <class name="com.xyz.Parent" table="PARENT" schema="FAMILY"> <meta attribute="implements" inherit="false">SomeInterface</meta> <meta attribute="extra-import" inherit="false">com.xyz.SomeInterface</meta> <property name="parentColumn" type="date"> <meta attribute="use-in-tostring" inherit="false">true</meta> <column name="PARENT_COLUMN" length="7" /> </property> <set name="child" table="Child" **inverse="false"** lazy="false" fetch="select" **cascade="all"**> <key> .... </key> <one-to-many class="com.xyz.Child" /> </set> </class> </hibernate-mapping>
排除Parent作为Child's hbm中的外键 - 避免在代码中反向查找。
<hibernate-mapping> <class name="com.xyz.Child" table="CHILD" schema="FAMILY"> <meta attribute="implements" inherit="false">SomeInterface</meta> <meta attribute="extra-import" inherit="false">com.xyz.SomeInterface</meta> <property name="childColumn" type="date"> <meta attribute="use-in-tostring" inherit="false">true</meta> <column name="CHILD_COLUMN" length="7" /> </property> </composite-id> **-- I do not want this in CHILD <many-to-one name="parent" class="com.xyz.Parent" update="false" insert="false" fetch="select"> <meta attribute="use-in-tostring" inherit="false">true</meta> .... </many-to-one>** </class> </hibernate-mapping>
有没有办法找出在DelegatingReverseEngineeringStrategy协会信息?某些类可以为每个表提供一对多,一对一的信息。