I've read though "How Do I Persist Inheritance?" in the FAQ, and write some codes to persist inheritance. My code contains 2 class, WebEntity and Category(inherit from WebEntity), each of them has a table also called WebEntity and Category. WebEntity can be persisted correctly, but when I call the save method of Category, it only save properties of Category to Category table, and the properties inherited form WebEntity did not save to the table which store information of WebEntity.
here's my code and xml file
public class WebEntity : CPersistentObject
{
public override bool IsValid()
{
return true;
}
public override CPersistentObject getNewObject()
{
return new WebEntity();
}
}
public class Category : WebEntity
{
private string name;
public string CategoryName
{
get
{
return name;
}
set
{
name = value;
SetDirtyFlag();
}
}
}
Hello Richard!
I've read though "How Do I Persist Inheritance?" in the FAQ, and write some codes to persist inheritance. My code contains 2 class, WebEntity and Category(inherit from WebEntity), each of them has a table also called WebEntity and Category. WebEntity can be persisted correctly, but when I call the save method of Category, it only save properties of Category to Category table, and the properties inherited form WebEntity did not save to the table which store information of WebEntity.
here's my code and xml file
public class WebEntity : CPersistentObject
{
public override bool IsValid()
{
return true;
}
public override CPersistentObject getNewObject()
{
return new WebEntity();
}
}
public class Category : WebEntity
{
private string name;
public string CategoryName
{
get
{
return name;
}
set
{
name = value;
SetDirtyFlag();
}
}
}
<class name="WebEntity" table="WebEntity" database="AM_DB">
<attribute name="OIDValue" column="OIDValue" key="primary"/>
<attribute name="CreatedDate" column="CreatedDate" timestamp="true"/>
<attribute name="ModifiedDate" column="ModifiedDate" timestamp="true"/>
</class>
<class name="Category" table="Category" database="AM_DB" superclass="WebEntity">
<attribute name="OIDValue" column="OIDValue" key="primary" reference="OIDValue"/>
<attribute name="CategoryName" column="CategoryName"/>
</class>
Did I miss anything?
Thank you very much~
The classes look OK. Can you post the generated SQL (it will be in the debug output window)