【发布时间】:2012-08-09 14:36:49
【问题描述】:
我想映射一个相当简单(我认为)的类:
<class name="parent" table="PARENT_TABLE">
<composite-id>
<key-property name = "a" column = "A"/>
<key-property name = "b" column = "B"/>
<key-property name = "c" column = "C"/>
</composite-id>
<map name = "theMap" table = "PARENT_TABLE" where="type='access'">
<key foreign-key = "PARENT_TABLE_FK">
<column name = "A"/>
<column name = "B"/>
<column name = "C"/>
</key>
<map-key column = "X" type = "double"/>
<element column = "Y" type = "double" not-null="true"/>
</map>
</class>
我从mapping multiple sets in one table in hibernate 得到了where="type='access'" 技巧,但问题是在映射中,外键 (A,B,C,X) 与父表 (A,B, C)。
有没有人知道如何让这个快乐?如果我必须单独映射地图,则 PARENT_TABLE 将是完全多余的。
【问题讨论】:
-
不排队是什么意思? A、B、C 是否不是唯一的,但对于每个 X、Y 组合都是重复的?
-
如,它希望父项的键与子项的键匹配,因为它是一个映射并且具有额外的键列'X',所以这是不可能的。您是正确的,每个子行都重复了 ABC。我要做的是防止两个表的 ABC 列具有相同的数据。
标签: java hibernate collections map