cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matt Kerr <>
Subject Re: Newbie Question: Mapping a Collection of Strings
Date Wed, 26 Aug 2009 02:55:15 GMT
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

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 :-?

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.

On Tue, Aug 25, 2009 at 10:08 PM, Bret Gregory<> 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.

View raw message