Hi!
I have the same problem. How do I model a optional foreign key????
Here are my mapping files:
Code:
<hibernate-mapping>
<class
name="metainf.anwendungskern.metainfoManagement.db.AttributeMetainformation"
table="ET_ATMI_ATTRIBUTE_META_INFORMATION">
<composite-id name="primaryKey" class="metainf.anwendungskern.metainfoManagement.db.AttributeMetainformationPK">
<key-many-to-one name="attribute" class="metainf.anwendungskern.attributeManagement.db.Attribute" column="ATTR_KEY"/>
<key-many-to-one name="useCase" class="metainf.anwendungskern.usecaseManagement.db.UseCase" column="USE_CASE_CONFIG"/>
</composite-id>
<many-to-one
name="attributeGroup"
cascade="none"
column="ATGR_KEY"
foreign-key="FK_ATTRIBUTEGROUP"
lazy="false"
fetch="join"/>
<!-- This one should be optional -->
<many-to-one
name="attributeClass"
cascade="none"
lazy="false"
column="ATCL_KEY"
foreign-key="FK_ATTRIBUTECLASS"
fetch="join"/>
... something other...
</class>
</hibernate-mapping>
Code:
<hibernate-mapping>
<class
name="metainf.anwendungskern.metainfoManagement.db.AttributeClass"
table="ET_ATCL_ATTRIBUTE_CLASS"
batch-size="5">
<id name="attributeClassKey" type="metainf.db.TrimmedString">
<column name="ATCL_KEY"/>
</id>
</class>
</hibernate-mapping>
AttributeClass should be optional. Have anyone a solution?
Thanks in advance.
regards,
Pierre