Try making one a collection descriptor with getters and setters that
operate on only a single object in the collection  and the other a
reference descriptor.  It's not the most elegant solution, but it works
and is supported by OJB as is.  I think in the next version of OJB, a
<inverse-foreignkey> should be added to the reference descriptor to
allow the FK column to exist in either table in a 1-1 relationship.

Try this...

Public class Customer {

        protected List businessPartner;

        public Customer() {
                businessPartner = new ArrayList();
        }

        public BusinessPartner getBusinessPartner() {
                return businessPartner.get(0);
        }

        public void setBusinessPartner(BusinessPartner bp) {
                this.businessPartner.add(0, bp);
        }
...
}
Then declare as a collection in repository.

-----Original Message-----
From: Stephan Wannenwetsch [mailto:[EMAIL PROTECTED] 
Sent: Thursday, December 11, 2003 2:06 AM
To: OJB Users List
Subject: RE: 1:1 relationship


Hallo Olli,

thanks for your reply, now it works better, but not as I want it.

What I want was a bidirectional 1:1 relationship but this one is only
unidirectional. I can get the BusinessPartner from the Customer but not
the otherway round.

Also the FK_CUST column in the DB is NULL but I'm not sure if I need
such a column, because in my opinion the key entry in the OJB_CUSTOMER
table should be enough!?

I hope you can help me with this issue, too ;-)

Thanks,

Stephan


-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Monday, December 08, 2003 6:54 PM
To: [EMAIL PROTECTED]
Subject: RE: 1:1 relationship


Hej Stephan

> -----Original Message-----

>       <reference-descriptor
[...]
>               <foreignkey>
>                        field-ref="fk_cust""

here, field-ref should not be xml-content
but an attribute in the opening tag.

>               </foreignkey>
>       </reference-descriptor>

HTH,
  Olli

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to