Quantcast
Channel: Apache Timeline
Viewing all articles
Browse latest Browse all 5648

equals() method for LoadableDetachableModels

$
0
0
I’ve started using CheckingObjectOutputStream to test for models of database objects that are not properly detached, and find it very useful.

However I just diagnosed (after many hours of frustration) that it can also cause problems rather than solve them. CheckingObjectOutputStream causes the equals() method of models to be called, and in the case of our models the equals() implementation loads the database object (models of the same object being considered equal to each other). Since it’s doing this during serialization and thus after the detach process, the checker actually causes the exact problem that it’s supposed to prevent (and doesn’t generate any warnings in this case).

Is it a general rule, that I was just not aware of, that detachable models should never use getObject() in their implementation of equals()? Or should CheckingObjectOutputStream be changed to avoid calling equals() ?

Bng

Viewing all articles
Browse latest Browse all 5648

Trending Articles