Sure, I need the link table.
I read throught the examples in the link you gave before posting, my problem is that I do not have and don't want to make the relationship
explicit on the object level. I.e. Persons or Address do NOT have a collection pointing to the other type. The collection descriptor
contains an attribute name refering to field to hold the relation. There is no such example on the page.
How do I define the relationship if no such field exists on the object level ?
The attributes sourcetype and targettype are used so what I can do a generic access to the link table - the link table can thus describe relationships between any kind of object. The approach works well for small numbers of links since it is quite flexible.
This is also the reason for not having a reference inside the value object pointing to the linked class.
Thanks for your help,
Stefan Schl�sser
Mahler Thomas wrote:
The only thing whcih seems to be a bit non-standard is the usage of attributes sourcetype and targettype. I don't see why such attributes are required?
IMO you just need a LINK table with the following DDL
CREATE TABLE LINK ( ADDRESS_ID INT NOT NULL, PERSON_ID INT NOT NULL, PRIMARY KEY (ADDRESS_ID, PERSON_ID) );
You won't an Entity class, but can define the m:n in the collection-descriptors fpr Address and Person.
>Hi, >I would like to know how to describe the following relations in the > repository.xml. > > class Address{ //no reference to Person > static long type = 1; > long id; > > String streetName; > } > > class Link{ //links Persons and address by id and type > long sourcetype; > long sourceid; > > long targettype; > long targetid;y > } > > class Person{ //no reference to Address > static long type = 2; > long id; > > String firstName; > } > > I know how to map the individual classes but how do I describe a > relationship between Addresses and Persons ? > The relationship is defined such that it exists if a link with the > sourcetype=1, targettype=2 and the ids of the objects exists. > > I don't want to retrieve Persons when loading addresses, > hence no Person > or Address field referencing the other class exists - but be > able to do > a query to retrieve all Persons with a specific streetName. > > Is that possible with OJB ? > > If not, how do I need to change the model to make it work ? > > Also I do not wish to carry the type field in each object, is there a > way to get rid of it and specifiy it in the repository descriptor > directly (with the value) ? > > Is there a solution which avoids putting references of one class into > the other ? > > Thanks for any ideas. > > Stefan Schl�sser
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
