Hi,
I am new to Hibernate and the reference paper does not really help me....at least I am unsure...
Here is my concrete example:
Table Question
question_id (pk)
question_text
Table Option
option id (pk)
question_id (pk, fk)
option_text
**********************
I have modelled this in java with the help of a third class (composite-class), that encapsulates the primary key for Option...
...now I read in the reference that -when using composite ids- one has
to override the equals() and the hashCode() methods...
Now my Question:
1. Which of the classes has to overwrite these methods?? The (non-persistent) Helper-class or the (persistent) Options-class??
2.) According to the reference I must not compare the identifyer values (these would be question_id+option_id)....instead one shall compare a "natural candidate key" - so, the only choice can be option_text in this case, which would mean, that equals() has to be overwritten only in the Options-class.....IS THAT RIGHT???....
|