Bruce,
What I want is to have a many-many relation between Session and Station. One session has a number of participating stations, with different roles (e.g. one station is sender and the rest are receivers). One station can participate in many sessions in different roles.

An example for a query that I would like to perform is to get a Session, including the name of the participating Stations, and the role they play in that Session, i.e. information is needed from all three tables.

One possible way to map it with Castor is of course to have a 1-many relation between Session and Participant, and then load the Station information in a second step based on the Participant information. Are there any better ways to do it? I could also change the DDL if there are better ways to model the problem...

Thanks

/ Orjan

Bruce Snyder wrote:

This one time, at band camp, Orjan Palsson said:

OP>
OP>I would like to make a many to many relation with a role classifier on
OP>the relation. Is it possible with Castor JDO? In that case - how? I have
OP>checked the JDO examples and the test cases, and there are only normal
OP>many-many relations without role classifier.
OP>
OP>/ Orjan
OP>
OP>Below is an example of the mapping file and the corresponding tables:
OP>
OP><mapping>
OP>
OP> <key-generator name="MAX" alias="normal">
OP> </key-generator>
OP>
OP> <class name="Station"
OP> identity="id" key-generator="normal">
OP> <description>A station participating in a session</description>
OP> <map-to table="Station" />
OP> <field name="id" type="integer" >
OP> <sql name="stationId" type="integer"/>
OP> </field>
OP> <field name="name" type="string">
OP> <sql name="name" type="varchar" />
OP> </field>
OP> </class>
OP>
OP> <class name="Session"
OP> identity="id" key-generator="normal">
OP> <description>A send/receive session</description>
OP> <map-to table="Session" />
OP> <field name="id" type="integer" >
OP> <sql name="sessionId" type="integer"/>
OP> </field>
OP> <field name="name" type="string">
OP> <sql name="name" type="varchar" />
OP> </field>
OP> <field name="participants" type="Station"
OP> collection="vector">
OP> <sql name="stationId"
OP> many-table="Participant" many-key="sessionId"/>
OP> </field>
OP> </class>
OP>
OP></mapping>
OP>
OP>Create table Session (
OP> sessionId Int NOT NULL ,
OP> name Varchar(20) ,
OP> UNIQUE (sessionId),
OP> Primary Key (sessionId));
OP>
OP>Create table Station (
OP> stationId Int NOT NULL ,
OP> name Varchar(20),
OP> UNIQUE (stationId),
OP> Primary Key (stationId));
OP>
OP>Create table Participant (
OP> role Char(5) NOT NULL , // SEND, RECEIVE, etc.
OP> stationId Int NOT NULL ,
OP> sessionId Int NOT NULL ,
OP> Primary Key (stationId,sessionId));

Orjan,

The JDO examples provide an example of a many-to-many mapping between
Product and Category. Is this not sufficent? However, seeing the
DDL above, I don't see how Participant.role would be a many-to-many?
Can you explain further what you want to do?

Bruce
--

perl -e 'print unpack("u30","<0G)U8V4\@4VYY9&5R\"F9E<G)E=\$\!F<FEI+F-O;0\`\`");'

----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev



----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev

Reply via email to