【问题标题】:coldfusion 9 orm - how to define relationshipColdfusion 9 orm - 如何定义关系
【发布时间】:2010-11-23 14:20:20
【问题描述】:

现在假设你有一个这样的数据库结构:

对象

{
    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
}

在这种情况下你们会如何定义父属性?请记住,根元素显然没有父对象。

【问题讨论】:

  • 我认为您只想为孩子和父母提供一对多
  • 我不这么认为,那样我会得到一个内部连接,并且不会列出/获取没有父对象的对象

标签: database orm coldfusion coldfusion-9


【解决方案1】:

这就是你要找的吗?

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";
}

【讨论】:

    猜你喜欢
    • 2012-01-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-17
    • 1970-01-01
    • 2015-04-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多