I am experiencing some behaviour that to me looks to be a bug, but I just need quick affirmation to know whether I should post the code and mapping files.
I have an exact replica of the Parent/Child example in my code. I am in the *Parent* class attempting to to ascertain if the Parent contains the Child (Here TimeSheetItem is the Child, and TimeSheet is the Parent), before I try to delete it. I cant remember if the Parent/Child example is lazy load, but mine is, so keep that in mind.
Under any circumstances, (barring concurrent modifications; there is only one thread accessing this method, it cannot have anything to do with concurrency (from the perspective of my code at least)) Could the two print statements within the for loop print true, and the print statement which checks if the element is contained print false. This code is in the same method, and nothing is called, in between nor, are any other threads running. It would seem to me that the contains method might have a bug, I have overidden equals in my classes, but it would seem that by virtue of printing true above, the contains method should certainly return true, no _ ?
Code:
for (Iterator ir = getTimeSheetItems().iterator(); ir.hasNext(); ) {
TimeSheetItem i = (TimeSheetItem) ir.next();
System.out.println(tsi.equals(i));
System.out.println(i.equals(tsi));
}
System.out.println(getTimeSheetItems().contains(tsi));