Hello everybody,
 
I've following - probably very trivial - problem:
 
I've 3 tables and 3 classes: 
* table TPerson (has foreign key to table TPersonType Not Null) and class CPerson (has attribute objPersonType of class CPersonType - pointer to child object attribute),  
* table TPersonType (has foreign key to table TPersonTypeCategory Not Null) and class CPersonType (has attribute objPersonTypeCategory of class CPersonTypeCategory - pointer child object attribute),
* table TPersonTypeCategory and class CPersonTypeCategory.
 
I set access="shared" for all classes in the mapp.xml.
I'm able to load required objPersonType and perform creating new objPerson via new CPersonType() and set previously loaded child object attribute then I called
db.create(objPerson). Everything is OK, Foreign key to TPersonType is also set OK.
 
During another scenario I need to refresh objPerson in Castor Cache form DB and want to avoid other JDBC apps modify objPerson  -  I load objPerson as db.locked => master object objPerson is locked in DB and all DB records corresponding to child objects (objPersonType and onjPersonTypeCategory) were also locked (until db.commit).
My problem is that I don't want to lock child objects in this scenario, I want to lock & update just objPerson.
When I changed access="read-only" for child classes (CPersonType and CPersonTypeCategory) - no child object lock was present (it's OK), but I wasn't able create new obj Person - there was DB error thrown (ORA-02291)- Parent key has not found - that means value for foreign key ID_FK_PERSON_TYPE is not correctly provided by CASTOR.
 
So,  how to avoid locking & updating of whole hierarchy of child objects when only master object locking is required - but having possibility to correctly update child object attribute pointer  - that is objPerson.setObjPersonType(objPersonType1). Note that modifying of objPersonType1 itself is never required during runtime - it's some kind of pre-configured data.
 
Could you please be so kind and help me ?
Thanks a lot for your help
 
Richard
 
 
 
here's the fragment from mapp.xml - it shows how is child object attribute configured:
    <class auto-complete="false" name="package1.CPerson" access="shared"
        key-generator="HIGH-LOW" identity="ID">
        <description>Default mapping for class package1.CPerson</description>
        <cache-type capacity="1000" type="count-limited"/>
        <map-to table="TPerson" xml="CPerson"/>
  <field required="false" transient="false" direct="false"
            name="objPersonType" type="package1.CPersonType" lazy="false">
            <sql name="ID_FK_PERSON_TYPE" dirty="check" read-/>
            <bind-xml node="element" name="objPersonType"/>
        </field>
 
...
 
 

Reply via email to