I have a parent class that has a field that I want to use in the unique constraing of many of the child classes. Is this possible, or do I need to simply move this field to the child class?
Code:
class Parent {
String name;
}
class ChildOne extends Parent {
}
class ChildTwo extends Parent {
}
What I want is that each ChildOne will have a unique name with respect to other ChildOne instances. Each ChildTwo will have a unique name with respect to other ChildTwo instances. It does not matter if ChildOne and ChildTwo share the same name.
Possible, without moving name to child? I am using joined-subclass. Obviously Hibernate is going to have to put the 'name' property in the child table to accomplish this.
Having name on the parent
class is the more OO way, but its not a big deal to move it.