Title: JDO: problem with read-only objects

Hi,

I have a problem with the mapping when mixing read-only and editable
tables in JDO:

The hypothesis are :
        - we have a table "Employee" with a 1-N relation to table "Company"
        - table "Company" is mapped read-only
        - relation employee-company is mapped normally : object
myapp.Employee has a field "company" of type myapp.Company

Now suppose we do the following in a transaction:
        1) load company "A" and company "B"
        2) create a new Employee with company "A"
        3) make it persistent with with db.create()
        4) change company: set it to "B"
        5) commit transaction

Commit fails, due to a check in preStore method of ClassMolder.


In my understanding, this is what happens:
        a) in class TransactionContext: since the class Company is mapped in
"read-only" mode, any of the myapp.Company objects participating
to current transaction are moved from HashTable _objects
into _readOnlyObjects (in method makeReadOnly)
        b) in class ClassMolder, when performing preStore(), because
relation to company has changed,
it is updated, and this is where unconsistency arises:
at the end of the switch: case FieldMolder.PERSISTANCECAPABLE:
   if ( value != null && !tx.isRecorded( value ) )
      throw new PersistenceException(
      "Object, "+object+", links to another object,"+value
      +" that is not loaded/updated/created in this transaction");

I solved the problem adding the following limitation to the check :
       && !tx.isReadOnly( value )





is this problem referenced ?


thanks,


Vincent Gautier.









=========================================================================
Ce message et toutes les pi�ces jointes sont propri�t� de VALTECH et
susceptibles de contenir des informations confidentielles � l'intention
exclusive de ses destinataires. Si vous avez re�u ce message par erreur
ou si celui ci vous est parvenu incomplet ou alt�r�, merci d'en avertir
l'exp�diteur par retour.Toute utilisation, diffusion ou publication non
express�ment autoris�e par nous par �crit est strictement interdite.
 --------------------------------------------------------------------------
This message and any attachments are Valtech property and may contain
iconfidential information intended solely for the addressees. If your are
not the intended recipient of this message or if you have received it
uncomplete or altered, please notify the author by replying to his e-mail
immediately. Any unauthorised use, diffusion or dissemination not
expressly authorised by us in writing is strictly prohibited.
=========================================================================
Copyright Valtech 2002


Reply via email to