How can I handle 1:1 relationships?

Iris Soto <[email protected]>
Newsgroups gmane.comp.jakarta.ojb.devel
Message-ID <[email protected]>
Hello all,
I've problems  to handle 1:1 relationships, I want this association is 
navigable on both sides, from person to passport and vice versa.
I'm working with OJB and Postgresql, how can i declare in the ojb 
descriptor, in the schema this type of relationships, i try this way, 
but i get the following error:
proxy.IndirectionHandler - Can not materialize object for Identity 
org.apache.ojb.Person{25} - using PBKey org.apache.ojb.broker.PBKey: 
jcdAlias=default, user=postgres, password=*****
-- 
--------------------------------------------------------------------------------------- 
and to remove it shows:
java.lang.NullPointerException
       at 
org.apache.ojb.broker.core.PersistenceBrokerImpl.doDelete(PersistenceBrokerImpl.java:608) 

       at 
org.apache.ojb.broker.core.PersistenceBrokerImpl.deleteReferences(PersistenceBrokerImpl.java:803) 

       at 
org.apache.ojb.broker.core.PersistenceBrokerImpl.performDeletion(PersistenceBrokerImpl.java:674) 

-- 
--------------------------------------------------------------------------------------- 


My schema.sql is thus:

CREATE TABLE Person
(
   person_id         INT NOT NULL PRIMARY KEY,
   person_name        VARCHAR(60),
)

CREATE TABLE Passport
(
   person_id       INT NOT NULL PRIMARY KEY,
   passport_number VARCHAR(20),
   foreign key(person_id) references Person(person_id) on update CASCADE 
on delete CASCADE
)

In my ojb descriptor I have the following:

<class-descriptor class="org.apache.ojb.Passport" table="PASSPORT">
     <field-descriptor name="personId" primarykey="true" 
nullable="false" column="PERSON_ID" jdbc-type="INTEGER"/>
     <field-descriptor name="passport_number" nullable="false" 
default-fetch="true" column="PASSPORT_NUMBER" jdbc-type="VARCHAR"/>
     <reference-descriptor name="personIdRef" 
class-ref="org.apache.ojb.Person" auto-update="false" 
auto-delete="false" proxy="true">
         <foreignkey field-ref="personId"/>
       </reference-descriptor>
   </class-descriptor>
****************************************************************
<class-descriptor class="org.apache.ojb.Person" table="PERSON">
       <field-descriptor name="personId" primarykey="true" 
nullable="false" autoincrement="true"... column="PERSON_ID" 
jdbc-type="INTEGER"/>
     <field-descriptor name="personName" nullable="false" 
default-fetch="true" column="PERSON_NAME" jdbc-type="VARCHAR"/>
       <reference-descriptor name="personPassIdRef" 
class-ref="org.apache.ojb.Passport" auto-update="true" 
auto-delete="true" proxy="true">
         <foreignkey field-ref="personId"/>
       </reference-descriptor>
</class-descriptor>

Thanks in advanced.

-- 
Iris Soto
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.