now pretend you have a db structure like this:
table Object
{
id,
开发者_如何学编程 name
}
table ObjectRelation
{
id,
parentID, -- points to id in the object table
childID -- points to id in the object table
}
what i'd like to have in my model is the following:
{
property name
property children
property parent
}
how would you guys define the parent property in this case? keep in mind that the root element(s) obviously don't have a parent object.
Is this what you were looking for?
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";
}
精彩评论