Actually the Question is in the title.
The entities will be map Comments for different objects in system(Blog nodes, comments, etc.)
so I want to be able work with this column(read it’s value for building comment tree for particular type of Commented object type.
Also I want to add @DiscriminatorColumn in the equals and hashcode methods.
What is the best way to do this?
This problem comes as whenever you load the entity, the discriminator value is always null. So if you try to add the discriminator value in equals you might get null pointer, So to do so there are two ways:-
insert="false" update="false"on to that attribute, which will make your attribute read only, and then for that attribute you can put the equals.eg:-