Supose i've got to entities: PERSON and CAR. They had a one-to-one relationship, in the CAR's table there is a foreign-key to PERSON - CO_PERSON. Do i have do map the CO_PERSON as a cmp-field and then make the relationship? Or i just have to make the relationship and put the name of the field? Thanks.
Howdy -- if I understand this correctly... if you have a one-to-one relationship between CAR and PERSON, and they are both entities, and you want it to be bi-directional (where CAR has a reference to PERSON and PERSON has a reference to CAR), then you can start with the PERSON entity and define a CMR field that holds the local component interface for the CAR entity, and then set-up a relationship for CAR and PERSON in the deployment descriptor. Also, since it is bi-directional, be sure to put a CMR field for PERSON inside the CAR bean (again, which references the local component interface for the PERSON). If you want it to uni-directional, where PERSON has a reference to CAR, but CAR does not need a reference to PERSON, then define a CAR CMR field inside PERSON, but don't put any CMR field for PERSON inside CAR. Then when you define the relationship between them in the DD, you will *not* list a CMR field for the CAR side of the relationship. And remember, you can also choose to define a cascade-delete, if you want the CAR to be automatically deleted if the PERSON is deleted. In that case, just be sure to put the cascade-delete tag inside the CAR side of the relationship. By saying that CAR has a cascade-delete capability, this means that if the other partner in the relationship is removed, then CAR will be removed automatically. Cascade-delete tags say to the Container, "Delete ME if my relationship partner is deleted." (in other words, do a remove() on me if someone does a remove() on my partner). You probably wouldn't want to set up a cascade-delete for the PERSON, because that would mean that if the CAR is removed, the PERSON will be deleted as well! That would be like saying, "If my car is totalled (wrecked in an accident), you might as well kill me too..." OK, so that's more than you needed to hear... but I was on a roll. cheers, Kathy
"If you like the book, don't tell me... tell Amazon." - a starving writer