cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Aristedes Maniatis <...@maniatis.org>
Subject Re: Mapping Question
Date Wed, 13 Apr 2011 02:12:00 GMT
On 13/04/11 5:43 AM, Tony Giaccone wrote:
> I have a number of entities, Think Topic, Project, Category, Asset.  On each
> one I need to model a to many relationship to Notes, Where a Note is an
> object with a subject and a date created and content.

Another approach is this:

DB tables:

Topic
Project
Asset
Note
NoteRelationship


Object Entities:

Topic
Project
Asset
Note
NoteTopicRelationship
NoteAssetRelationship
NoteProjectRelationship

Use inheritance to set this structure up in Cayenne. A discriminator column in the NoteRelationship
will define how the joins work. In the modeler, put something like "entityIdentifier = 1"
 into the NoteTopicRelationship and"entityIdentifier = 2" into the NoteAssetRelationship,
etc

The advantage of this approach is that you get a many to many join and the Java code looks
very readable and clear.


Ari



-- 
-------------------------->
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A

Mime
View raw message