Re: The right tool for integration to existing DB

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Wed Apr 27 2005 - 14:07:47 EDT

  • Next message: enrico: "Use of cayenne in caucho resin"

    > For example, class C has properties cprop1 and cprop2 directly mapped to
    > specific columns, and property cprop3 which is an object of type class
    > D. Class D has properties dprop1 and dprop2 that will be mapped to other
    > columns.

    > Is it possible to establish a mapping from a set of tables to a main
    > class where some of the columns will be "normally" mapped to the main
    > class properties and some other columns will be mapped to another class
    > that will need to be instantiated and set into the main class.

    I assume both of these paragraphs talk about the same scenario? Namely one
    table mapped to a composition of classes...

    This is one of the manual cases, as each persistent object requires an
    identity (and object "D" will not have it in a database sense). So you
    will have to "fake" the composition of C and D working on top of a single
    DataObject.

    You can create C and D "wrappers" outside of Cayenne. But here is another
    idea... I haven't tried this myself, but it should work. How about you
    declare C and D as interfaces, and then create a DataObject that
    implements both of them. So it would look like this:

    interface C {
      String getCprop1();
      ...
      D getD();
    }

    interface D {
      ...
    }

    public CDObject extends _CDObject /*extends CayenneDataObject */
     implements C, D {

      public D getD() {
         return this;
      }
    }

    Andrus



    This archive was generated by hypermail 2.0.0 : Wed Apr 27 2005 - 14:07:48 EDT