[ 
https://issues.apache.org/cayenne/browse/CAY-1112?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Laurent Marchal updated CAY-1112:
---------------------------------

    Attachment: SQL_trace_log.txt

Query log, with explanation of what is done

> Fetching from relationships returns TRANSIENT objects.
> ------------------------------------------------------
>
>                 Key: CAY-1112
>                 URL: https://issues.apache.org/cayenne/browse/CAY-1112
>             Project: Cayenne
>          Issue Type: Bug
>          Components: Cayenne Core Library
>    Affects Versions: 3.0
>         Environment: Linux, Ubuntu 8.04, Cayenne 3.0.M4
>            Reporter: Laurent Marchal
>            Assignee: Andrus Adamchik
>         Attachments: SQL_trace_log.txt
>
>
> There is a relationship between MasterJob--->MasterJobAux where i checked "To 
> Dep PK" since no ARTIST_AUX rows can exists without corresponding MasterJob.
> When i fetch a MasterJob i have added a prefetch for MasterJobAux :
> query.addPrefetch(MasterJob.RELATED_MASTER_JOB_AUX_PROPERTY);
> Code I use to get/create/delete MasterJobAux
>               protected MasterJobAux createAux(ILookupFieldCodes fieldCode, 
> Short seqNo, String value) {
>                       MasterJobAux aux = 
> MasterJob.this.getObjectContext().newObject(MasterJobAux.class);
>                       aux.setScheduleId(MasterJob.this.getScheduleId());
>                       aux.setJobName(MasterJob.this.getJobName());
>                       
>                       aux.setJaFieldCode((int) fieldCode.getID());
>                       aux.setJaSequenceNumber(seqNo);
>                       aux.setJavalue(value);
>                       aux.setRelatedMasterJob(MasterJob.this);
>                       return aux;
>               }
>               protected List<MasterJobAux> fetchAuxList() throws 
> OpconException {
>                       return MasterJob.this.getRelatedMasterJobAux();
>               }
>               protected void deleteAux(MasterJobAux toDelete) throws 
> OpconException {
>                       MasterJob.this.removeFromRelatedMasterJobAux(toDelete);
>                       
> MasterJob.this.getObjectContext().deleteObject(toDelete);
>               }
> Cayenne XML :
>       <obj-entity name="MasterJob" 
> className="com.sma.core.api.master.MasterJob" dbEntityName="JMASTER" 
> superClassName="com.sma.core.api.DataAccessObject">
>               <obj-attribute name="accessCodeId" type="java.lang.Short" 
> db-attribute-path="ACCESSCDID"/>
>               <obj-attribute name="altenateMachine1Id" type="java.lang.Short" 
> db-attribute-path="ALTMACH1ID"/>
>               <obj-attribute name="altenateMachine2Id" type="java.lang.Short" 
> db-attribute-path="ALTMACH2ID"/>
>               <obj-attribute name="altenateMachine3Id" type="java.lang.Short" 
> db-attribute-path="ALTMACH3ID"/>
>               <obj-attribute name="deptartmentId" type="java.lang.Short" 
> db-attribute-path="DEPTID"/>
>               <obj-attribute name="estimatedRuntime" type="java.lang.Integer" 
> db-attribute-path="ESTRUNTIME"/>
>               <obj-attribute name="jobGroupId" type="java.lang.Short" 
> db-attribute-path="JOBGROUPID"/>
>               <obj-attribute name="jobName" type="java.lang.String" 
> db-attribute-path="JOBNAME"/>
>               <obj-attribute name="jobTypeId" type="java.lang.Short" 
> db-attribute-path="JOBTYPE"/>
>               <obj-attribute name="machineGroupId" type="java.lang.Short" 
> db-attribute-path="MACHGRPID"/>
>               <obj-attribute name="primaryMachineId" type="java.lang.Short" 
> db-attribute-path="PRIMMACHID"/>
>               <obj-attribute name="scheduleId" type="java.lang.Integer" 
> db-attribute-path="SKDID"/>
>               <obj-attribute name="shortName" type="java.lang.String" 
> db-attribute-path="SHORTNAME"/>
>       </obj-entity>
>       <obj-entity name="MasterJobAux" 
> className="com.sma.core.api.auxs.MasterJobAux" dbEntityName="JMASTER_AUX" 
> superClassName="com.sma.core.api.DataAccessObject">
>               <obj-attribute name="jaFieldCode" type="java.lang.Integer" 
> db-attribute-path="JAFC"/>
>               <obj-attribute name="jaSequenceNumber" type="java.lang.Short" 
> db-attribute-path="JASEQNO"/>
>               <obj-attribute name="javalue" type="java.lang.String" 
> db-attribute-path="JAVALUE"/>
>               <obj-attribute name="jobName" type="java.lang.String" 
> db-attribute-path="JOBNAME"/>
>               <obj-attribute name="scheduleId" type="java.lang.Integer" 
> db-attribute-path="SKDID"/>
>       </obj-entity>
>       <db-relationship name="toMasterJobAux" source="JMASTER" 
> target="JMASTER_AUX" toDependentPK="true" toMany="true">
>               <db-attribute-pair source="SKDID" target="SKDID"/>
>               <db-attribute-pair source="JOBNAME" target="JOBNAME"/>
>       </db-relationship>
>       <obj-relationship name="relatedMasterJobAux" source="MasterJob" 
> target="MasterJobAux" db-relationship-path="toMasterJobAux"/>
> To reproduce the problem :
> 1) Fetch MasterJobAux  using the relationships
>       MasterJob.getRelatedMasterJobAux();
> 2) delete/create some MasterJobAux
>       MasterJob.removeFromRelatedMasterJobAux(toDelete);
>       MasterJob.getObjectContext().deleteObject(toDelete);
> 3) Rollback
> 4) re-Fetch MasterJobAux  using the relationships
>       MasterJob.getRelatedMasterJobAux();
> I get TRANSIENT objects, you can look a the SQL log attached where there is 
> some others details.
> Thanks.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to