[英]coldfusion 9 orm - how to define relationship
现在假装您具有这样的数据库结构:
表对象
{
id,
name
}
表ObjectRelation
{
id,
parentID, -- points to id in the object table
childID -- points to id in the object table
}
我想在模型中包含以下内容:
{
property name
property children
property parent
}
在这种情况下,你们将如何定义父属性? 请记住,根元素显然没有父对象。
这是您要找的东西吗?
component persistent="true" {
property name="id" ormtype="integer" type="numeric" column="id" fieldtype="id" generator="identity";
property name="name";
property name="children"
fieldtype="one-to-many"
cfc="Object"
linktable="ObjectRelation"
fkcolumn="parentID"
singularname="child"
lazy=true
inversejoincolumn="childID";
property name="parent"
fieldtype="many-to-one"
cfc="Object"
linktable="ObjectRelation"
fkcolumn="childID"
lazy=true
inversejoincolumn="parentID";
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.