Menu

How to persist inheritance with attributes

2004-10-05
2013-03-07
  • Nobody/Anonymous

    Hi,

    I've tried to persist inheritance by using attributes, but I dont know how to use it correct:

    My SUPERCLASS:

    [AFTable("MyBusinessObjects", "Test", AFTableAttribute.KeyType.useOIDValue,
             OIDColumn="oid",         CreatedTimestamp="CreatedDate",         ModifiedTimestamp="ModifiedDate")]
        public class MyBusinessObject : CPersistentObject
        {...}

    SUBCLASS:

    [AFTable("MyBusinessObjects",
    "Test",
    AFTableAttribute.KeyType.useOIDValue,
    OIDColumn="oid",
    SuperClass=typeof(MyBusinessObject),
    KeyReference="OIDValue",             SharedTableField="IType",             SharedTableValue="1")]
    public class MyBusinessObject1 : MyBusinessObject
    {...}

    Is there something wrong?? because I get the error:
    "Object reference not set to an instance of an object."

    Thanks and Regards
    Lene
       

     
    • Richard Banks

      Richard Banks - 2004-10-06

      Hi Lene,

      The code looks OK at first glance.  Have you isolated the line of code that actually causes the error?

      - Richard.

       
    • Nobody/Anonymous

      Hi Richard,

      the error occurs in CPersistentBroker Reflect(..) :

      "If Not afTable.KeyReference Is Nothing And Not afTable.SuperClass Is Nothing Then
                                  refAttr = ClassMap.SuperClass.getAttributeMapByString(afTable.KeyReference, True)..."

      But ClassMap.Superclass instance is not set yet(= nothing)
      -> Error:"Object reference not set to an instance of an object."

      Lene

       
    • Richard Banks

      Richard Banks - 2004-10-06

      Ah.  Got it :-)

      Please get the latest version of CPersistenceBroker from CVS and try that.  It should be OK now.

      Please note that the public CVS takes a little while to update.

       

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.