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 Jair da Silva Ferreira JĂșnior <j2...@amazon.com.br> on 2003/09/17 01:21:46 UTC
collection-descriptor orderby attribute fetches wrong field value
Hi,
I am using ojb1.0_rc4, ODMG api with OJB queries and mysql4. I will describe my problem with an example for you to better understand it.
1) I have a class called ClassA, another class called ClassB and another class called ClassC.
2) ClassA has a collection of ClassB objects which has a reference to a ClassC object. So, ClassA is 1:N associated with ClassB. ClassB is N:1 associated with ClassC.
3) ClassB has a field called _startTime. ClassC has also a field called _startTime. So, both classes have a field with the same name.
4) I use the following collection-descriptor for ClassA in my repository_user.xml file:
<class-descriptor
class="ClassA"
table="class_a">
.....
<collection-descriptor
name="_classBObjects"
element-class-ref="ClassB"
orderby="_classCObject._startTime"
sort="ASC"
>
<inverse-foreignkey field-id-ref="2"/>
</collection-descriptor>
....
</class-descriptor>
5) The problem is that when I load a ClassA object, the _classBObjects list is populated with ClassB objects which have wrong values for the _startTime field. The values in ClassB._startTime objects are actually values from classC._startTime objects. This is wrong!
6) After some investigation I found out that this happens because of the orderby attribute in collection-descriptor. When I change the orderby element from orderby="_classCObject._startTime" to orderby="_id" the problem disappears.
I believe this is a bug in OJB. Please, does anyone know how to solve this problem?
Thanks for your help.
Sincerely,
Jair Jr