posted 13 years ago
Hello Arun,
The idea was to have Hibernate compare each result of type Foo with the given object foo, by using the equals method.
I had Hibernate generate the domain classes and I was hoping that Foo would either contain its own implementation of 'equals' method, or that Hibernate would be able to compare two objects foo of type Foo 'under the hood' in some smart way (e.g. comparing each property by reflection).
I guess neither is the case and therefore it is probably not possible to provide DetachedCriteria with an object foo, so that Hibernate will leave out any result for which result.equals(foo) returns true.
The Collection.remove(foo) option does also not work because of the same reason: since Foo does not implement its own version of equals, two objects are compared by hashcode and this obviously fails all the time (I hadn't tried it yet).
So what I did in the end is add a criterion for id comparison:
...which works for me.
Thanks,
Kjeld
Kjeld Sigtermans - SCJP 1.4 - SCWCD 1.4