You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Eric Kelm <er...@vsgadmin.com> on 2006/03/09 16:06:02 UTC

Problem with collection using ODMG API

Hi all-

I am having a problem with 1:n collection in OJB using ODMG.

Say I have a parent object, lets call it Trouble Ticket "T" with a
collection of Ticket Notes "N". Lets say that the objects retrieved in list
"N" are "n1, n2, n3". 

I perform a retrieval from the DB on Object T. Now I have T with a list of
child objects N.

When I perform an update on object T using the ODMG API, all child objects
that were brought in on the retrieval are reinserted on the update even
though there were no changes to these objects, so once update is complete I
have object T which updated list N, but now I have double the notes
associated with object T, so now I have n1, n2, n3, n1, n2, n3. 

I am using OJB 1.0.4 release. Following is code from repository_user.xml

 
<class-descriptor
	class="com.xxx.xxx.businessobjects.ServiceTicketBO"
	table="service_tickets"
	isolation-level="read-uncommitted"
>
		<field-descriptor
			name="id"
			column="idSERVICE_TICKET"
			jdbc_type="INTEGER"
			primarykey="true"
            access="readonly"
            autoincrement="true"
		/>
		...
		<!--other fields-->
		...
		<!--reference descriptors-->
		...
		<collection-descriptor
			name="notes"
	
element-class-ref="com.xxx.xxx.businessobjects.ServiceTicketNoteBO"
			proxy="false"
			auto-retrieve="true"
			auto-update="none"
			auto-delete="none">
			<inverse-foreignkey field-ref="idServiceTicket" />
			<orderby name="dateTimeEntered" sort="DESC"/>
		</collection-descriptor>
</class-descriptor>

 



---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: Problem with collection using ODMG API

Posted by Armin Waibel <ar...@apache.org>.
Hi Eric,

Eric Kelm wrote:
> Hi all-
> 
> I am having a problem with 1:n collection in OJB using ODMG.
> 
> Say I have a parent object, lets call it Trouble Ticket "T" with a
> collection of Ticket Notes "N". Lets say that the objects retrieved in list
> "N" are "n1, n2, n3". 
> 
> I perform a retrieval from the DB on Object T. Now I have T with a list of
> child objects N.
> 
> When I perform an update on object T using the ODMG API, all child objects
> that were brought in on the retrieval are reinserted on the update even
> though there were no changes to these objects, so once update is complete I
> have object T which updated list N, but now I have double the notes
> associated with object T, so now I have n1, n2, n3, n1, n2, n3. 
> 

Are the PK fields of n1...n3 are populated on the retrieval?

I never noticed this problem in OJB 1.0.4. Could you provide some sample 
code to reproduce this issue? In this case I can setup a test in OJB's 
test-suite.

regards,
Armin


> I am using OJB 1.0.4 release. Following is code from repository_user.xml
> 
>  
> <class-descriptor
> 	class="com.xxx.xxx.businessobjects.ServiceTicketBO"
> 	table="service_tickets"
> 	isolation-level="read-uncommitted"
> 		<field-descriptor
> 			name="id"
> 			column="idSERVICE_TICKET"
> 			jdbc_type="INTEGER"
> 			primarykey="true"
>             access="readonly"
>             autoincrement="true"
> 		/>
> 		...
> 		<!--other fields-->
> 		...
> 		<!--reference descriptors-->
> 		...
> 		<collection-descriptor
> 			name="notes"
> 	
> element-class-ref="com.xxx.xxx.businessobjects.ServiceTicketNoteBO"
> 			proxy="false"
> 			auto-retrieve="true"
> 			auto-update="none"
> 			auto-delete="none">
> 			<inverse-foreignkey field-ref="idServiceTicket" />
> 			<orderby name="dateTimeEntered" sort="DESC"/>
> 		</collection-descriptor>
> </class-descriptor>
> 
>  
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org