English 中文(简体)
我如何将一个实体从一个类别转换为另一个类别?
原标题:How do I convert an entity from one type to another in ColdFusion ORM?

请允许我指出,我有三个实体,即<代码>Company、StandardCompanyCompanyTemplate,其中Company是另外两个实体的基础类别:

                Company
                  /
                 /  
                /    
  StandardCompany    CompanyTemplate

And the component mappings:

component name="Company" mappedSuperClass="true"
{
    property name="Name";
}

component name="StandardCompany" persistent="true" extends="Company"
{
    property name="Owner";
}

component name="CompanyTemplate" persistent="true" extends="Company"
{
    property name="UsageCount";
}

用户应当有能力转换任何<代码>。 标准Company至CompanyTemplate,并再次编号。 我知道,我可以建立一个新的<条码>。 CompanyTemplate 每当用户想要转换<代码>StandardCompany时:

function ConvertToTemplate(StandardCompany company)
{
    var template = EntityNew("CompanyTemplate");
    // copy all properties from company to template
    EntitySave(template);
}

但是,这将产生新的记录,并打破旧公司的任何账簿。 我只想将其转换成<>CompanyTemplate,而不会产生任何新的记录。 I m 采用表层分布图。

我怎样才能做到这一点,只是修改<代码>Company的 /strong>,而不必为之创造新的记录?

最佳回答

How can I accomplish this by just modifying the type of the Company, without having to create a new record for it?

我们不能。 页: 1

如果您使用nofollow”,每个分流中分层中分层有分层:>,你可以改变discriminatorColumn/>。 然后,你可以修改“不必创建新记录”。

问题回答

暂无回答




相关问题
Entity Framework with File-Based Database

I am in the process of developing a desktop application that needs a database. The application is currently targeted to SQL Express 2005 and works wonderfully. However, I m not crazy about having ...

Assistance with CakePHP model relationships

How would I represent the following in a CakePHP model? Product ======= product_id .... Cart ==== cart_id .... Carts_Products ============== cart_id product_id quantity

join across databases with nhibernate

I am trying to join two tables that reside in two different databases. Every time, I try to join I get the following error: An association from the table xxx refers to an unmapped class. If the ...

How are Models (in MVC) and DAOs supposed to interact?

How are models and DAOs supposed to interact? I m in the process of putting together a simple login module and I m unsure where to put the "business logic." If I put the logic with the data in the ...

Convert date to string upon saving a doctrine record

I m trying to migrate one of my PHP projects to Doctrine. I ve never used it before so there are a few things I don t understand. In my current code, I have a class similar to this: class ...