Menu

How to associate class without oid?

2005-01-27
2013-03-07
  • Nobody/Anonymous

    Hi,Richard

         I don't use oid or guid.
         MyClass1 has two primary key.
         and MyClass2 has three primary key.

         example as:

    MyClass1 :
    key1 as string
    key2 as string

    MyClass2 :
    key1 as string
    key2 as string
    key3 as string

    <class name="MyClass1" table="TABLE1" database="Sample1">
    <attribute name="KEY1" column="KEY1" key="primary" find="true"/>
    <attribute name="KEY2" column="KEY2" key="primary" find="true"/>
    <attribute name="CreatedDate" column="CREATEDDATE" timestamp="true"/>
    <attribute name="ModifiedDate" column="MODIFIEDDATE" timestamp="true"/>
    <attribute name="MyClass2s"/>
    </class>
    <class name="MyClass2" table="TABLE2" database="Sample1">
    <attribute name="KEY1" column="KEY1" key="primary" find="true"/>
    <attribute name="KEY2" column="KEY2" key="primary" find="true"/>
    <attribute name="KEY3" column="KEY3" key="primary" find="true"/>
    <attribute name="CreatedDate" column="CREATEDDATE" timestamp="true"/>
    <attribute name="ModifiedDate" column="MODIFIEDDATE" timestamp="true"/>
    <attribute name="Name" column="DESCRIPTION" proxy="true"/>
    </class>

    <association fromClass="MyClass1" toClass="MyClass2"
    cardinality="oneToMany" target="MyClass2s"
    retrieveAutomatic="true" deleteAutomatic="true" saveAutomatic="true" inverse="false">
    <entry fromAttribute="?" toAttribute="?"/>
    </association>

    How can i do about association?
    Thank you.
    ANYA

     
    • Richard Banks

      Richard Banks - 2005-01-27

      Hi Anya,

      Firstly, Class1 will need attributes to reference to class2's key fields such as class2Key1, class2Key2, etc

      Secondly in your association simply put multiple <entry /> entities such as

      <association fromClass="MyClass1" toClass="MyClass2" 
      cardinality="oneToMany" target="MyClass2s" 
      retrieveAutomatic="true" deleteAutomatic="true" saveAutomatic="true" inverse="false">
      <entry fromAttribute="class2Key1" toAttribute="KEY1"/>
      <entry fromAttribute="class2Key2" toAttribute="KEY2"/>
      <entry fromAttribute="class2Key3" toAttribute="KEY3"/>
      </association>

       

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.