Menu

Problem using sql server

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

    I got a problem using sql server, here's my xml file.
    <?xml version="1.0" encoding="utf-8" ?>
    <map>
        <database name="TestAtomsFramwork" class="CMsSqlDatabase">
            <parameter name="server" value="localhost" />
            <parameter name="user" value="sa" />
            <parameter name="password" value="abc" />
            <parameter name="OIDTable" value="OID"/>
        </database>
       
        <class name="Article" table="Article" database="TestAtomsFramwork">
            <attribute name="OIDValue" column="oid" key="primary"/>
            <attribute name="CreatedDate" column="CreatedDate" timestamp="true"/>
            <attribute name="ModifiedDate" column="ModifiedDate" timestamp="true"/>
            <attribute name="Title" column="Title" proxy="true"/>
            <attribute name="PublishedDate" column="PublishedDate" proxy="true"/>
            <attribute name="Click" column="Click" proxy="true"/>
            <attribute name="IsImageArticle" column="IsImageArticle" />
            <attribute name="AtomsDetailOIDValue" column="AtomsDetailOIDValue" />
        </class>
       
        <class name="ArticleDetail" table="ArticleDetail" database="TestAtomsFramwork">
            <attribute name="OIDValue" column="oid" key="primary"/>
            <attribute name="CreatedDate" column="CreatedDate" timestamp="true"/>
            <attribute name="ModifiedDate" column="ModifiedDate" timestamp="true"/>
        </class>
       
        <class name="ArticleImage" table="ArticleImage" database="TestAtomsFramwork">
            <attribute name="OIDValue" column="oid" key="primary"/>
            <attribute name="CreatedDate" column="CreatedDate" timestamp="true"/>
            <attribute name="ModifiedDate" column="ModifiedDate" timestamp="true"/>
            <attribute name="AtomsArticleOIDValue" column="AtomsArticleOIDValue" timestamp="true"/>
        </class>
       
        <association fromClass="Article"
            toClass="ArticleDetail"
            cardinality="oneToOne"
            target="Detail"
            retrieveAutomatic="true"
            deleteAutomatic="true"
            saveAutomatic="true"
            inverse="false">
            <entry fromAttribute="AtomsDetailOIDValue" toAttribute="OIDValue"/>
        </association>
       
        <association fromClass="Article"
            toClass="ArticleImage"
            cardinality="oneToMany"
            target="Images"
            retrieveAutomatic="true"
            deleteAutomatic="true"
            saveAutomatic="true"
            inverse="false">
            <entry fromAttribute="OIDValue" toAttribute="AtomsArticleOIDValue"/>
        </association>
       
    </map>

    When I call the Init() method of PersistentBroker, an exception was thrown :

    TestCase 'TestAtomsFramework.Test.TestArticle.TestSaveFields' failed: System.NullReferenceException : Object reference not set to an instance of an object.
        C:\Projects\MMM\Atoms_Framework\CXMLConfigLoader.vb(348,0): at AToMSFramework.CXMLConfigLoader.getClassMap(XmlElement node)
        C:\Projects\MMM\Atoms_Framework\CXMLConfigLoader.vb(171,0): at AToMSFramework.CXMLConfigLoader.IConfigLoader_loadConfig(HybridDictionary& dbMap, HybridDictionary& clMap)
        C:\Projects\MMM\Atoms_Framework\CPersistenceBroker.vb(1134,0): at AToMSFramework.CPersistenceBroker.loadConfig(_IConfigLoader configLoader)
        C:\Projects\MMM\Atoms_Framework\modPersistenceBrokerSingleton.vb(126,0): at AToMSFramework.modPersistenceBrokerSingleton.getPersistenceBrokerInstance(String xmlfile)
        C:\Projects\MMM\Atoms_Framework\CPersistenceBroker.vb(1062,0): at AToMSFramework.CPersistenceBroker.init(String xmlfile)
        d:\test\testatomsframework\test\testarticle.cs(31,0): at TestAtomsFramework.Test.TestArticle.SetUp()

    Can you tell me how to solve this problem?

    Thank you.

     
    • Richard Banks

      Richard Banks - 2004-10-25

      The most obvious thing is that you have a target specified for an association (ie "Details") but you haven't included that in the XML mapping yet.

      Your Article class should be something like this:

      <class name="Article" table="Article" database="TestAtomsFramwork">
      <attribute name="OIDValue" column="oid" key="primary"/>
      <attribute name="CreatedDate" column="CreatedDate" timestamp="true"/>
      <attribute name="ModifiedDate" column="ModifiedDate" timestamp="true"/>
      <attribute name="Title" column="Title" proxy="true"/>
      <attribute name="PublishedDate" column="PublishedDate" proxy="true"/>
      <attribute name="Click" column="Click" proxy="true"/>
      <attribute name="IsImageArticle" column="IsImageArticle" />
      <attribute name="AtomsDetailOIDValue" column="AtomsDetailOIDValue" />
      <attribute name="Details" />
      <attribute name="Images" />
      </class>

      the last two attributes are required as they are the target of the association (even though they don't map to a database column).

      You have also set AtomsArticleOIDValue (in articleimages) as a timestamp field.  Looks like a cut and paste error there :-)

      Also proxy="true'" is the default for all attributes.

      - Richard.

       
    • Nobody/Anonymous

      I get it!

      Thanks again! : )

       

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.