I commit the changes. Please test again. :)


Thomas

-----Original Message-----
>From: Thomas Yip [mailto:[EMAIL PROTECTED]]
>Sent: Thursday, August 02, 2001 11:09 AM
>To: [EMAIL PROTECTED]
>Subject: Re: [castor-dev] Object creation problem!
>
>Arr... sound like you have self-reference object. Although self-reference
is
>not support, I will put an additional check to avoid StackOverFlow.
>
>
>Thomas
>
>-----Original Message-----
>>From: Francois Maurit [mailto:[EMAIL PROTECTED]]
>>Sent: Thursday, August 02, 2001 5:19 AM
>>To: [EMAIL PROTECTED]
>>Subject: Re: [castor-dev] Object creation problem!
>>
>>I encounter a java.lang.StackOverflowError when using the updated CVS.
>>
>>I'll try to give some details about the context, but I didn't dig very far
>>in castor code.
>>
>>Attached is the mapping file.
>>
>>The code causing the exception is :
>>
>>    DBVersion lo_version = lo_vue.version;
>>    lo_version.setDate(new Date());
>>
>>    //l'entr�e � modifier
>>    DBEntree lo_entree = null;
>>
>>    DBEntree lo_entreeTemporaire = getEntreeTemporaire();
>>
>>    try {
>>        Database lo_db = jdo.getDatabase();
>>        lo_db.setAutoStore(true);
>>        try {
>>            log.debug("\t<transaction>");
>>            lo_db.begin();
>>            log.debug("\t\t<cr�ation de " + lo_entree + ">");
>>
>>            //inclusion de la cat�gorie dans la transaction
>>            lo_entree = (DBEntree) lo_db.load(DBEntree.class,
>>lo_vue.idObjetPrincipal);
>>
>>            if (lo_vue.direct) {
>>                //�changer les donn�es entre l'entr�e et la version
>>                String lo_tmp;
>>                lo_tmp = lo_entree.getDescription();
>>                lo_entree.setDescription(lo_version.getDescription());
>>                lo_version.setDescription(lo_tmp);
>>                lo_tmp = lo_entree.getNom();
>>                lo_entree.setNom(lo_version.getNom());
>>                lo_version.setNom(lo_tmp);
>>                //l'URL change tj, nouveau fichier ou nouvelle adresse
>>                //MAIS v�rifier pr�sence fichier avant
>>                lo_tmp = lo_entree.getURL();
>>                lo_entree.setURL(lo_version.getURL());
>>                lo_version.setURL(lo_tmp);
>>
>>                Date lo_date = lo_entree.getDate();
>>                lo_entree.setDate(lo_version.getDate());
>>                lo_version.setDate(lo_date);
>>
>>                lo_version.setRaison(lo_vue.remarque);
>>
>>                lo_entree.addVersion(lo_version);
>>            }
>>            else {
>>                //lo_db.update(lo_entreeTemporaire);
>>                lo_entreeTemporaire =
>>                    (DBEntree) lo_db.load(DBEntree.class,
>>lo_entreeTemporaire.getId());
>>                lo_entreeTemporaire.addVersion(lo_version);
>>            }
>>            //inclusion de l'utilisateur (load car risque de conflit si
>>update)
>>            Integer lo_idUtilisateur = lo_vue.utilisateur.getId();
>>            lo_version.setUtilisateur(
>>                (DBUtilisateur) lo_db.load(DBUtilisateur.class,
>>lo_idUtilisateur));
>>
>>            //enfin on rend persistente la nouvelle version
>>            lo_db.create(lo_version);
>>
>>            log.debug("\t</transaction>");
>>            lo_db.commit();
>>            log.debug("</connexion>");
>>            lo_db.close();
>>        }
>>        catch (PersistenceException e) {
>>            log.error("Impossible de sauver la donn�e : " + e);
>>            throw new DatabaseException("Impossible de sauver la donn�e");
>>        }
>>        finally {
>>            //rien � mettre (g�r� par castor)
>>        }
>>    }
>>    catch (PersistenceException e) {
>>        log.error("Impossible d'ouvrir la connexion : " + e);
>>        throw new DatabaseException("Impossible d'ouvrir la connexion");
>>    };
>>
>>(hope you won't blame me to much for writing such code - DBVersion is a
new
>>object not persistent before the transaction).
>>The exception occurs when calling lo_db.create(lo_version) on Castor's
code
>>:
>>
>>    public int getPriority() {
>>        if ( _priority == -1 ) {
>>            int maxPrior = 0;
>>            for ( int i = 0; i < _fhs.length; i++ ) {
>>                if ( _fhs[i].isPersistanceCapable() && _fhs[i].isStored()
>>                        &&
>>_fhs[i].getFieldClassMolder().isKeyGeneratorUsed() ) {
>>                    maxPrior = Math.max( maxPrior,
>>_fhs[i].getFieldClassMolder().getPriority()+1 );
>>                }
>>                /* should an "if case" for add _ids[i].isForeginKey() in
>the
>>future */
>>            }
>>            _priority  = maxPrior;
>>        }
>>        return _priority;
>>    }
>>
>>"_fhs[i].getFieldClassMolder().getPriority()" keeps returning the same
>>"ClassMolder fr.improve.bdi.mapping.jdo.DBCat" object resutling in an
>infini
>>te loop.
>>
>>Hope there are enough clues to help you fix the problem. Otherwise I can
>>send you my code and database creation script.
>>
>>    Fran�ois
>>
>>----- Original Message -----
>>From: "Thomas Yip" <[EMAIL PROTECTED]>
>>To: <[EMAIL PROTECTED]>
>>Sent: Thursday, August 02, 2001 2:08 AM
>>Subject: [castor-dev] Object creation problem!
>>
>>
>>> Hi all,
>>>
>>> I just made a major enhancement to Castor JDO to solve the problem users
>>> reported over the last month regarding object creation in different
>>> situations. (it was more major than I first planned, so does the time
>>spent)
>>>
>>> The enhancements split the object creation into two phases. It first
>walks
>>> from the specified object, and mark all related (if autoStore is true),
>>and
>>> dependent object to be created. It then create object according to the
>>> determined priority.
>>>
>>> A priority is determined bases on if the object has any foreign key to
>>> key-generated object, and if that key-generated object contains foreign
>>key
>>> to another key-generated object, and if that......
>>>
>>> Could please everybody who reported creation problem, especially with
>>> key-generation, and different access mode pull the most update-to-date
>>code
>>> from the cvs to see if your problems solved? (Especially Master's
>>> dependent's related object, or "insert null" into non-null key-generated
>>> foreign key columns)
>>>
>>> One issue are that I have to broke the test case Persistent for now. I
am
>>> looking for workaround on that right now.
>>>
>>>
>>> Please test the cvs now and don't wait until the next release,
otherwise,
>>> all other creation situations might be solved but not yours.
>>>
>>>
>>>
>>> Thank you very much, all JDO users.
>>>
>>>
>>>
>>> Thomas
>>>
>>> -----------------------------------------------------------
>>> If you wish to unsubscribe from this mailing, send mail to
>>> [EMAIL PROTECTED] with a subject of:
>>> unsubscribe castor-dev
>>>
>>>
>>
>
>-----------------------------------------------------------
>If you wish to unsubscribe from this mailing, send mail to
>[EMAIL PROTECTED] with a subject of:
>        unsubscribe castor-dev
>

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to