【发布时间】:2014-04-02 16:43:13
【问题描述】:
在 ColdFusion 9.0.2 中,我试图将实体(发布)中的两个一对一关系\属性(createdBy 和 modifiedBy)映射到同一个表\实体(用户)和同一列(用户 ID)我遇到以下错误:
实体映射中的重复列:发布列:createdBy(应使用 insert="false" update="false" 映射)
当我更改创建者和修改帖子的用户时,我需要修改这两种关系。如果我从发布实体中删除其中一个关系 createdBy 或 modifiedBy 则没有问题,因此 CF 和/或 ORM 似乎不喜欢这两个属性指向另一个实体的同一列。
带有 FK 约束的 SQL
CREATE TABLE posting (
postingID int IDENTITY (1,1) NOT NULL,
name varchar(35) NOT NULL,
createdBy int NOT NULL,
modifiedBy int NOT NULL,
PRIMARY KEY (postingID),
CONSTRAINT fk_postingCreatedBy FOREIGN KEY (createdBy) REFERENCES user(ID),
CONSTRAINT fk_postingModifiedBy FOREIGN KEY (modifiedBy) REFERENCES user(ID)
);
发布具有关系的实体
component persistent="true" table="posting" schema="dbo" output="false" {
// properties
property name="postingID" type="numeric" fieldtype="id" generator="identity";
property name="name" type="string";
// relationships
property name="createdBy" fieldtype="one-to-one" cfc="user";
property name="modifiedBy" fieldtype="one-to-one" cfc="user";
}
用户实体
component persistent="true" table="user" schema="dbo" output="false" {
// properties
property name="userID" column="ID" type="numeric" fieldtype="id" generator="identity";
property name="firstName" type="string";
property name="lastName" type="string";
}
我尝试了几种方法来解决这个问题,但无济于事。我也找不到针对 ColdFusion ORM 的任何帮助,甚至我发现的其他语言的其他问题/帖子/Hibernate 的使用也不符合我的具体情况。
非常感谢任何帮助或信息!
【问题讨论】:
标签: sql-server hibernate orm coldfusion coldfusion-9