cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nishant Neeraj <>
Subject Re: Using Join Table
Date Thu, 10 Sep 2009 10:23:48 GMT
I am sorry all the formatting messed up.Here is the link to DB model image
- Nishant

--- On Thu, 10/9/09, Nishant Neeraj <> wrote:

From: Nishant Neeraj <>
Subject: Using Join Table
Date: Thursday, 10 September, 2009, 3:34 PM

I am new to ORM and Cayenne. I a pretty puzzled by relationship flattening and the way we
use Modeller to achieve this.[1]
For example, I have 4 tables. Magazines, Subscriptions, Readers and Subscription_Types.Subscription
is essentially a "join" table that makes many-to-many relationship between Readers and magazines.
Subscription_Types is a table which is used to mark each magazine and reader relationship.
(hopefully the diagram below explains this)

Magazines -------->> Subscriptions <<-------- ReadersSubscription_Types -------^^

My goal is to do this:

1. Magazine object should have List of Readers in such a way that I can get SubscriptionType
object from it. That is, 
subscriptionObject = magazineObject.getReadersList().get(i).getSubscriptionType()
2. The same way, I should be able to do similar action from Readers side. Such that If I have
a readers object I can get all associated magazines and the subscriptionType of each magazine.
-------I am a bit confused because

1. I have to join by primary key, if I want to do "to dep PK". The problem is, doing so, I
do not see any foreign-key column in dependent (Subscriptions) table. If I create explicit
foreign key columns and join using them, I can't check "to Dep PK".
2. Coming to relationship flattening. I can flatten the relationship between readers and magazines...
but the issue is, we have another dimension to it - SubscriptionType. I am not sure how to
incorporate this attribute in each reader and magazine when accessed as mentioned in the goals
Since I do not see place where query is created or how flattening is done (from DB point of
view) in Cayenne, I feel a little uncomfortable with Relationship flattening.
I am going through Cayenne 2 documentations, user guide, Map.xml and a bit of source code.
Though the brevity of explanations and lack of real-world example is a bit annoying. 
I am used to DAO, VO kind of architecture; with Cayenne (or probably any ORM tool) being everything
implicit, I am going cold feet.
Any help would be appreciated. ---[1]

      Love Cricket? Check out live scores, photos, video highlights and more. Click here

      See the Web&#39;s breaking stories, chosen by people like you. Check out Yahoo!
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message