我將ResourcePermission
添加到對象Report
。每個Query
對象可以具有一對一的關係。 A Query
延伸Resource
並有ResourcePermission
在一對多(一個查詢許多權限)。將類映射到現有對象列表時,'重複列映射'
我需要將相同的屬性添加到與Query
關聯的Report
對象,因爲它可以具有不同的權限。當我添加列表和地圖中的一個Query
很多Permission
關係我得到
Caused by: org.hibernate.MappingException: Repeated column in mapping for entity: com.bio.ResourcePermission column: resource_id (should be mapped with insert="false" update="false")
哪個我不理解爲什麼,在Report
不會擴展Query
或Resource
,因此沒有被映射兩次。對於多個一對多關係,表格可能不是many
?
<class name="com.bio.Report" table="REPORT">
<id name="id" type="long" column="id">
<generator class="foreign">
<param name="property">query</param>
</generator>
</id>
<property name="name" column="name"/>
<!--Trying to add this list mapping breaks it-->
<bag name="permissions" table="RESOURCE_PERMISSION">
<key column="resource_id" not-null="true"/>
<one-to-many class="com.bio.ResourcePermission"/>
</bag>
<!-- This query extends Resource-->
<one-to-one name="query" class="com.bio.Query" />
</class>
這是有ResourcePermissions
<class name="com.bio.Resource" table="RESOURCE">
<id name="id" type="long" column="id">
<generator class="native">
<param name="sequence">SEQ_RESOURCE_AUTO</param>
</generator>
</id>
<bag name="permissions" table="RESOURCE_PERMISSION" lazy="true" batch-size="50" cascade="all-delete-orphan">
<key column="resource_id" not-null="true"/>
<one-to-many class="com.bio.ResourcePermission"/>
</bag>
</class>
批准的地圖測繪
<class name="com.bio.ResourcePermission" table="RESOURCE_PERMISSION">
<id name="id" type="long" column="id">
<generator class="native">
<param name="sequence">SEQ_RES_PERM_AUTO</param>
</generator>
</id>
<property name="canEdit" column="edit"/>
<property name="canView" column="can_view"/>
<property name="canRun" column="run"/>
<property name="everyone" column="everyone"/>
</class>