Re: The right tool for integration to existing DB

From: Colin Surprenant (n..etaxia.com)
Date: Tue Apr 26 2005 - 22:50:05 EDT

  • Next message: Tore Halset: "Re: memory usage"

    I installed Cayenne and using the modeler application I was able to
    reverse engineer a few tables from a DB2 database, establish some
    relations, create some queries and auto generate the Java classes within
    one hour. Nice work! The modeler is really helpful to bootstrap a project.

    The classes I generated were one to one mapping of the DbEntities to
    the ObjEntities. What I want to achieve is a bit more complex and I
    could use a little more help.

    In the end, the Java class I want to map my DB tables to is a rather
    large class composed of other objects and collections.

    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.

    Is it possible to automate such a mapping or will I need to establish
    mappings for all my different parts and then compose my final object
    outside to Cayenne?

    Thanks for your help,
    Colin.

    Andrus Adamchik wrote:

    >>About switching DB, my idea was more of keeping the same object model
    >>for any new DB schema (& technology too). For example, a generic
    >>import-export class in your application that you need to map to
    >>different customer's specific data table (also using different DB
    >>engines - ok, covered with the DB Adapter). In the end you want to keep
    >>the same import-export class interface but only adapt the mapping
    >>between your class and the different customers DB schemas.
    >>
    >>
    >
    >I got it. Sure you can do it with Cayenne as mapping is completely
    >external to both Java and DB layers. In other words you can map a
    >"User.firstName" object property to "USER.FIRST_NAME" column in one DB and
    >to "login.fname" column in another.
    >
    >Andrus
    >
    >
    >



    This archive was generated by hypermail 2.0.0 : Tue Apr 26 2005 - 22:50:17 EDT