Menu

Mapping

2004-09-07
2004-09-09
  • Nobody/Anonymous

    How mappin many to many relation. I want use primary key and not OIDs

     
    • Nobody/Anonymous

      My classes is:
      Material has many Proveedor and Proveedor has many Material.
      I has three table (Proveedor, Material and ProveedorMaterial)

      Saludos

      Victor (Madrid - Spain)

       
    • Richard Banks

      Richard Banks - 2004-09-07

      Hi Victor,

      This is not a problem at all.

      In the association just make sure you have an entry for each attribute that will be used in the join (ie one for each key field).

      For example

      <association fromClass="A" toClass="B" cardinality="oneToMany" target="ColB" retrieveAutomatic="true" deleteAutomatic="false" saveAutomatic="false" inverse="false">
          <entry fromAttribute="B_AKey1" toAttribute="AKey1" />
          <entry fromAttribute="B_AKey2" toAttribute="AKey2" />
      </association>

      -Richard.

       
    • Nobody/Anonymous

      hi
      but, how specified the association.
      I can two class (Proveedor and Material) and i has three tables (Proveedor, material and ProveedorMaterial).
      I need a class ProveedorMAterial or not ?
      How relations this classes with tables

      Saludos

      Victor (Madrid - Spain)

       
    • Richard Banks

      Richard Banks - 2004-09-08

      Hi Victor,

      Yes, you will need the ProveedorMaterial class.

      Until I can work in a way to set a table purely for associations, you need a class for N-M associations.

       
    • Nobody/Anonymous

      Hi,

      Escuseme, but i don't understand how i can map my classes.
      Proveedor ... ProveedorMaterial (OneToMany) ?
      Material.....ProveedorMaterial (OneToMany) ?

      or

      How ??????????

      I need view all material of the proveedor in a DataGrid and all proveedor of the Material.

      Saludos

      Victor (Madrid - Spain)

       
      • Richard Banks

        Richard Banks - 2004-09-08

        Hi Victor,

        As a backgrounder, you may find this article useful as it explains different ways in which objects can be mapped to a relational database  http://www.agiledata.org/essays/mappingObjects.html

        For your specific situation you need

        (A = Proveedor, B=Material, AB = ProveedorMaterial)

           1 ..*      *..1
        A <--> AB <--> B

        So you XML mapping will have 4 associations.

        2 for the 1..* association of A to AB
        and 2 for the 1..* association of B to AB

        If you want a collection from Proveedor containing all just Materials (instead of ProveedorMaterials) then you can try to do the following:

        1. Override the retrieve() method in Proveedor.
        2. Call MyBase.Retrieve()
        3. Specifically copy the Materials objects from the ProveedorMaterials collection into a Materials collection
        for example...
        for each PM as ProveedorMaterial in Me.ProvedorMaterialsCol
          Me.MaterialsCol.Add(PM.Material)
        next

        I hope that makes a bit more sense for you.

        - Richard.

         
    • Nobody/Anonymous

      Thank you.

      All right

       

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.