我映射下列地图收集:休眠NULL值(XML映射)
<map name="customFields" table="table_name" fetch="select">
<key column="primary_id" />
<map-key-many-to-many column="custom_id" class="CustomField" />
<many-to-many column="other_id" class="AnotherClass" />
</map>
这个伟大的工程;如果列'primary_id
','custom_id
'和'other_id
'都填充了一个值,则所有记录都会添加到地图中。
但是,当'other_id'列为空时,该记录不会添加到地图中。有没有一个属性或者我可以强迫Hibernate将这些记录添加到Java Map?
可视化
+------------+-----------+----------+
| primary_id | custom_id | other_id | Added?
+------------+-----------+----------+
| 1 | 53 | 124 | YES
| 2 | 98 | 288 | YES
| 3 | 18 | NULL | NO
+------------+-----------+----------+
我不认为'不,null'属性是允许的。如果我添加一个,我偶然发现一个'Attribute“not-null”必须声明为元素类型“多对多”错误! –