Re: Newbie Question: Mapping a Collection of Strings

From: Matt Kerr (mat..entralparksoftware.com)
Date: Tue Aug 25 2009 - 22:55:15 EDT

  • Next message: Bret Gregory: "Re: Newbie Question: Mapping a Collection of Strings"

    Hey Bret -

    Unless I'm missing - yes, this is right on the mark for cayenne.

    If you have an existing database, the easiest is to create a new model
    and use Tools -> Re-engineer Databae Schema, ie
        http://cayenne.apache.org/doc/reverse-engineer-database.html

    Note- I find there a few quirks in the Modeler, so pay attention to
    the fine print like this,
    "... you need to select either a DataDomain or one of its children on
    the project tree."

    If you're starting from scratch - hmm, I'd thought there'd be more
    info here, but I'm not seeing it :-?
        http://cayenne.apache.org/doc/modeler-guide.html

    You'd need to do something *vaguely* like ..

    1/ create a Database Entity for each of your tables: Product and
    Keyword. This includes defining PK.
    2/ then still in the Database Entity - add the Relationship from
    Product -> Keyword. You have to open the Inspector (I) to define the
    columns which define the join. Set the name of reverse relationship
    -which will use the FK you mention.
    3/ when that's all set, I'd hit the "C+" (Create Object Entity) to
    define your classes.
    4/ Tools -> Generate Classes

    Hope this helps for now.
    -mk

    On Tue, Aug 25, 2009 at 10:08 PM, Bret Gregory<bmg12..ahoo.com> wrote:
    > I have a DB that looks something like this:
    >
    > Product
    > -ProductId
    > -Description
    >
    > Keyword
    > -ProductId
    > -Keyword
    >
    > Where Product -> Keyword is 1:N and Keyword has a FK rel back to Product.
    >
    > I would like the object model to look something like this:
    >
    > Product
    > -(String) _description
    > -(List<String>) _keywords
    >
    > Is it possible to map collections of simple objects and have them persisted by Cayenne?  Seems like this would be a pretty common request, but
    > I am not seeing a way to do this in the modeler.
    >
    >
    >
    >



    This archive was generated by hypermail 2.0.0 : Tue Aug 25 2009 - 22:55:50 EDT