cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrus Adamchik <and...@objectstyle.org>
Subject Re: 3.0M4 : Fetching from relationship returns TRANSIENT objects.
Date Thu, 25 Sep 2008 07:57:20 GMT
Hi Laurent,

sorry didn't have time to look at this yet. Yes, please open a Jira  
with these details. We'll try to get to it.

Thanks,
Andrus

On Sep 24, 2008, at 12:00 PM, Laurent Marchal wrote:

> Hello Andrus,
>
>   Have you some time to look at this problem, i think it's a bug. I  
> can file a bug if you want.
>
> Thanks.
>
> Laurent.
>
> Laurent Marchal wrote:
>> Hi Andrus,
>>
>> I post on the mailing list with a new mail adress, because my  
>> provider sucks....
>> I will try to detail more what i do, so you can reproduce this in  
>> your test case. Maybe i'ts because you don't have prefetching or  
>> "to dep PK".
>>
>> 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.
>>
>> Laurent marchal.
>>
>>> Hi,
>>>
>>> Sorry, you posted this earlier and looks like nobody replied yet.
>>>
>>> So my question is : is this normal to get *TRANSIENT* objects from  
>>> a relationship after a rollback ?
>>>
>>> No, it is not normal. I just created a test case to reproduce it  
>>> and things seem to be working ok:
>>>
>>> PaintingInfo info = ctxt.newObject(PaintingInfo.class);  
>>> info.setTextReview("XXX"); p1.setToPaintingInfo(info);
>>>
>>> assertSame(info, p1.getToPaintingInfo()); ctxt.rollbackChanges();  
>>> assertNull(p1.getToPaintingInfo());
>>>
>>> Does it look like the scenario that you have, or am I missing  
>>> something?
>>>
>>> Thanks, Andrus
>>>
>>> On Sep 15, 2008, at 12:22 PM, Laurent Marchal wrote:
>>>
>>> Hello again !
>>>
>>> I have a strange thing happening in Cayenne 3.0M4 : I have two  
>>> tables ARTIST and ARTIST_AUX where extended artist's properties  
>>> are stored.
>>>
>>> There is a relationship between ARTIST--->ARTIST_AUX where i  
>>> checked "To Dep PK" since no ARTIST_AUX rows can exists without  
>>> corresponding ARTIST.
>>>
>>> I have also a addPrefetch(ARTIST_AUX) when i retrieve ARTISTs.
>>>
>>> In my "artist editor" I create ARTIST_AUX rows at need and when an  
>>> error occurs i do a rollback(). The strange thing is that when i  
>>> refetch ARTISTS_AUX with the relationship, instead of getting only  
>>> existing ARTISTS_AUX, i get also the ARTISTS_AUX created before  
>>> the rollback() with the *TRANSIENT* state and no ObjectContext  
>>> associated.
>>>
>>> So my question is : is this normal to get *TRANSIENT* objects from  
>>> a relationship after a rollback ?
>>>
>>> Thanks Laurent Marchal.
>>>


Mime
View raw message