Hi Gerardo,

OJB is setting the FK field from the reference object.  Therefore,
setting the FK field and not setting the reference object is not
sufficient.  

You can solve this problem in one of two ways.

1.  Set the parentExamen object instead of the COD_EXAMEN_FISICO Fk
field.  OJB will set the COD_EXAMEN_FISICO FK field from the object
before doing a persistence operation.

2.  Set the COD_EXAMEN_FISICO field and call
pb.retrieveReference("parentExamen"); to have OJB resolve the reference
object.

Hope this helps.

Wally

-----Original Message-----
From: Gerardo Arroyo [mailto:[EMAIL PROTECTED] 
Sent: Monday, December 29, 2003 7:24 PM
To: 'OJB Users List'
Subject: Problem with reference-descriptor

Hi,

I had a very unusual problem with the reference-descriptor. I try to
insert a row in the database. There is a varchar-field named
'COD_EXAMEN_FISICO', which is a foreign-key.

OJB returns with an error indicating that the field 'COD_EXAMEN_FISICO'
could not be NULL. Now, I checked the object before the store and the
'COD_EXAMEN_FISICO' is NOT NULL at all; but still the RDBMS report the
error.

I did a simple test, removed the 'reference-descriptor' then tried the
same sentence and work smoothly. I put again the 'reference-descriptor'
and there is no way that I can fix it.

I debugged the source code and the "problem" is in the
assertFkAssignment method at
org.apache.ojb.broker.core.PersistenceBrokerImpl. Is this an error or
the expected behavior? 

The extract of the repository_user.xml is:

  <class-descriptor
     class="com.flecharoja.siis.data.SIIS_EXAMEN_FISICOData"
     table="SIIS_EXAMEN_FISICO"
  >
        <field-descriptor id="1"
                name="DSC_EXAMEN_FISICO"
                column="DSC_EXAMEN_FISICO"
                jdbc-type="VARCHAR"
        />
        <field-descriptor id="2"
                name="COD_EXAMEN_FISICO"
                column="COD_EXAMEN_FISICO"
                jdbc-type="VARCHAR"
                primarykey="true"
        />
  </class-descriptor>

  <class-descriptor
     class="com.flecharoja.siis.data.SIIS_EXAMEN_FISICO_PACIENTEData"
     table="SIIS_EXAMEN_FISICO_PACIENTE"
  >
        <field-descriptor id="1"
                name="NUM_IDENTIFICACION"
                column="NUM_IDENTIFICACION"
                jdbc-type="NUMERIC"
                primarykey="true"
        />
        <field-descriptor id="2"
                name="NUM_CITA"
                column="NUM_CITA"
                jdbc-type="VARCHAR"
                primarykey="true"
        />
        <field-descriptor id="3"
                name="COD_EXAMEN_FISICO"
                column="COD_EXAMEN_FISICO"
                jdbc-type="VARCHAR"
                primarykey="true"
        />
        <field-descriptor id="4"
                name="OBS_EXAMEN_FISICO_PACIENTE"
                column="OBS_EXAMEN_FISICO_PACIENTE"
                jdbc-type="VARCHAR"
        />
        <reference-descriptor name="parentExamen" 
        
class-ref="com.flecharoja.siis.data.SIIS_EXAMEN_FISICOData"
                refresh="true">
             <foreignkey field-id-ref = "3"/>    
        </reference-descriptor>
  </class-descriptor>

Note: I also tried with the      <foreignkey field-ref =
"COD_EXAMEN_FISICO"/> I am using OJB 1.0.rc3 -also tried with OJB
1.0.rc5

Thanks in advance!!!
Gerardo


---------------------------------------------------------------------
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