I use JPA/Hibernate, MySQL and Spring Roo and I am in the process of modeling an application that will have two different types of members:
As of now, I have one table/entity for both male and female members.
However, I am now realizing that some fields/attributes will be different according to whether the member is a male or female.
For instance, I can have an "beard style" attribute for men that will contains the following possible values: "trimmed, long, shaven".
I thought of several options to represent this in my domain model:
Can anyone please provide advice as to which of my options, if any, is acceptable. Or provide a better alternative?
I dislike the second approach. A male person object might contain a relation to FemaleSpecificInfo, that smells badly to me. I don't think that "composition over inheritance" implementation is right.
I'd try Hibernate inheritance. You should check the strategies . If male and female share most of the data I'd use Table per class hierarchy.