Dods: Re: Dods digest, Vol 1 #180 - 1 msg

Zvonimir Radulovic <[email protected]> Tue, 30 Dec 2003 02:16:37 -0800 (PST)
Newsgroups gmane.comp.java.enhydra.dods
Message-ID <[email protected]>
--0-1347141443-1072779397=:83472
Content-Type: text/plain; charset=us-ascii

Hi,
I correct this and I don't have this problem, I lose old exception stack trace :(
I am very satisfied with DODS, specially with preformance :),
caching dramatically optimize performace
 
This is part of my doml:
          <table dbTableName="firm" id="books.data.codebook.Firm">
            <column id="name" usedForQuery="true">
              <type dbType="VARCHAR" javaType="String" size="100"/>
            </column>
            . . . 
          </table>
          <table dbTableName="provider" id="books.data.codebook.Provider">
            <column id="code" usedForQuery="true">
              <type dbType="VARCHAR" javaType="String" size="6"/>
            </column>
            . . .  
            <column id="firm" usedForQuery="true">
              <referenceObject constraint="true" reference="books.data.codebook.Firm"/>
              <type dbType="none" javaType="books.data.codebook.FirmDO"/>
            </column>
          </table>
This is part of my Bussines class :
    
    public Provider() throws BusinessException {
        try {
            this.myDO = ProviderDO.createVirgin();
        } catch(DatabaseManagerException ex) {
            throw new BusinessException("Error creating empty Provider", ex);
        } catch(ObjectIdException ex) {
            throw new BusinessException("Error creating empty Provider", ex);
        }
    }
     . . . .
    public void save() throws BusinessException, AssertionDataObjectException {
        try {
            this.myDO.save();
        } catch(Exception ex) {
            throw new BusinessException("Error saving Provider", ex);
        }
    }
When I call save, DODS throws previous exception
The problem is in persistent attribute of Firm. Firm lose persistent (persistent become false)
    in checkDup() method od DO class 
    
    data = ((ProviderDataStruct)originalData).duplicate();
    
    provider reference objects lose persistent (FirmDO.persistent = false)
    
    ProviderDataStruct class duplicate() method  looks like:
        ret.code = GenericDO.copyString(code);
        ret.firm = books.data.codebook.FirmDO.createCopy( firm );   
        // This creates a DO that has no ObjectId but has a copy of an existing DO's data.
That was the problem. 
    
I correct that like follows:
1. change DataStruct template to produce next code:
    public ProviderDataStruct duplicate() 
    throws DatabaseManagerException, ObjectIdException {
        return duplicate(false);
    }
    public ProviderDataStruct duplicate(boolean noReference) 
    throws DatabaseManagerException, ObjectIdException {
        ProviderDataStruct ret = new ProviderDataStruct ();
        if (!isEmpty) {
                ret.code = GenericDO.copyString(code);
            if (noReference)
                ret.firm = firm;
            else 
                ret.firm = books.data.codebook.FirmDO.createCopy( firm );
        }
        ret.set_OId(get_OId());
        ret.set_Version(get_Version());
        ret.databaseName=get_Database();
        ret.isEmpty = isEmpty;
        return ret;
    }
2. change DO template to generate: 
    
     public void checkDup () throws DatabaseManagerException,   
com.lutris.appserver.server.sql.ObjectIdException {
         if (isDeletedFromDatabase)
             throw new DatabaseManagerException("Object "+get_OId()+" is deleted");
         if (null == data) {
             data = ((ProviderDataStruct)originalData).duplicate(true);
             data.readOnly = false;
         }
    }
That solved my problem, but I am not sure that is quite correct, because I don't understand this code.   
Regards,
Z. Radulovic





---------------------------------
Do you Yahoo!?
New Yahoo! Photos - easier uploading and sharing
--0-1347141443-1072779397=:83472
Content-Type: text/html; charset=us-ascii

<DIV>Hi,<BR>I correct this and I don't have this problem, I lose old exception stack trace :(<BR>I am very satisfied with DODS, specially with preformance :),<BR>caching dramatically optimize performace</DIV>
<DIV>&nbsp;</DIV>
<DIV>This is part of my doml:</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;table dbTableName="firm" id="books.data.codebook.Firm"&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;column id="name" usedForQuery="true"&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;type dbType="VARCHAR" javaType="String" size="100"/&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/column&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; . . .&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/table&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;table dbTableName="provider" id="books.data.codebook.Provider"&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;column id="code" usedForQuery="true"&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
 bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;type dbType="VARCHAR" javaType="String"
 size="6"/&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/column&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; . . .&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;column id="firm" usedForQuery="true"&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;referenceObject constraint="true" reference="books.data.codebook.Firm"/&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;type dbType="none" javaType="books.data.codebook.FirmDO"/&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/column&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/table&gt;</DIV>
<DIV>This is part of my Bussines class :<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; public Provider() throws BusinessException {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; try {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.myDO = ProviderDO.createVirgin();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } catch(DatabaseManagerException ex) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; throw new BusinessException("Error creating empty Provider", ex);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } catch(ObjectIdException ex) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; throw new BusinessException("Error creating empty Provider", ex);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp;&nbsp; . . . .</DIV>
<DIV>&nbsp;&nbsp;&nbsp; public void save() throws BusinessException, AssertionDataObjectException {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; try {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.myDO.save();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } catch(Exception ex) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; throw new BusinessException("Error saving Provider", ex);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; }</DIV>
<DIV>When I call save, DODS throws previous exception</DIV>
<DIV>The problem is in persistent attribute of Firm. Firm lose persistent (persistent become false)</DIV>
<DIV>&nbsp;&nbsp;&nbsp; in checkDup() method od DO class <BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; data = ((ProviderDataStruct)originalData).duplicate();<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; provider reference objects lose persistent (FirmDO.persistent = false)<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; ProviderDataStruct class duplicate() method&nbsp; looks like:</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ret.code = GenericDO.copyString(code);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ret.firm = books.data.codebook.FirmDO.createCopy( firm );&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // This creates a DO that has no ObjectId but has a copy of an existing DO's data.</DIV>
<DIV>That was the problem. <BR>&nbsp;&nbsp;&nbsp; <BR>I correct that like follows:</DIV>
<DIV>1. change DataStruct template to produce next code:</DIV>
<DIV>&nbsp;&nbsp;&nbsp; public ProviderDataStruct duplicate() <BR>&nbsp;&nbsp;&nbsp; throws DatabaseManagerException, ObjectIdException {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return duplicate(false);<BR>&nbsp;&nbsp;&nbsp; }</DIV>
<DIV>&nbsp;&nbsp;&nbsp; public ProviderDataStruct duplicate(boolean noReference) <BR>&nbsp;&nbsp;&nbsp; throws DatabaseManagerException, ObjectIdException {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ProviderDataStruct ret = new ProviderDataStruct ();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (!isEmpty) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ret.code = GenericDO.copyString(code);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (noReference)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ret.firm = firm;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ret.firm = books.data.codebook.FirmDO.createCopy( firm );<BR>&nbsp;&nbsp;&nbsp;&nb
 sp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 ret.set_OId(get_OId());<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ret.set_Version(get_Version());<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ret.databaseName=get_Database();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ret.isEmpty = isEmpty;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return ret;<BR>&nbsp;&nbsp;&nbsp; }</DIV>
<DIV>2. change DO template to generate: <BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp; public void checkDup () throws DatabaseManagerException,&nbsp;&nbsp;&nbsp;</DIV>
<DIV>com.lutris.appserver.server.sql.ObjectIdException {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (isDeletedFromDatabase)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; throw new DatabaseManagerException("Object "+get_OId()+" is deleted");<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (null == data) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; data = ((ProviderDataStruct)originalData).duplicate(true);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; data.readOnly = false;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; }</DIV>
<DIV>That solved my problem, but I am not sure that is quite correct, because I don't understand this code.&nbsp;&nbsp; </DIV>
<DIV>Regards,<BR>Z. Radulovic<BR></DIV><BR><BR><p><hr SIZE=1>
Do you Yahoo!?<br>
<a href="http://pa.yahoo.com/*http://us.rd.yahoo.com/evt=21260/*http://photos.yahoo.com">New Yahoo! Photos - easier uploading and sharing</a>
--0-1347141443-1072779397=:83472--