Menu

Problem while persisting inheritance

2004-08-06
2004-08-10
  • Nobody/Anonymous

    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~

     
    • Richard Banks

      Richard Banks - 2004-08-10

      The classes look OK.  Can you post the generated SQL (it will be in the debug output window)

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.