我使用的是CF9 ORM -
我有一个对象模型,其中我有多个对象,这些对象可能与一个特定的对象具有一对一的关系。有没有办法具体说明两种潜在的氯氟烃中的一种的反向关系?
氯氟化碳1a (ProblemType1):
property name="Product" cfc="Product" fieldtype="one-to-one" fkcolumn="productID" ;氯氟烃1b (ProblemType2):
property name="Product" cfc="Product" fieldtype="one-to-one" fkcolumn="productID" ;CFC2:
property name="Problem" fieldtype="one-to-one" cfc=???;我能为此使用一个接口吗?或者...?
发布于 2013-01-12 03:43:19
CFC1a和CFC1b都可以是父实体CFC1的子类。CFC1应该与"Product“有关系,这两个子类都将继承它。然后,CFC 2可以在其关系中指向CFC 1。
样例实体:
/** CFC 1 **/
component persistent="true" {
property name="Product" cfc="Product" fieldtype="one-to-one" fkcolumn="productID";
}
/** CFC 1a **/
component persistent="true" extends="baseProblem" {
// problemtype1 specific properties go here
}
/** CFC 1b **/
component persistent="true" extends="baseProblem" {
// problemtype2 specific properties go here
}
/** CFC 2 **/
component persistent="true" {
property name="Problem" fieldtype="one-to-one" cfc="baseProblem";
}如果采用这种方法,可能需要查看inheritance mapping,特别是discriminatorColumn和discriminatorValue属性。如果不知道DB模式是如何设置的,就很难就这一点给出进一步的建议,但文档应该可以帮助您入门。
https://stackoverflow.com/questions/14284325
复制相似问题