Reputation: 26
I have created pojo classes using hibernate auto code generation. It has maintained reference to child in bases class (through set ). If i introduce new table which depends on base table and generate code again. This time it will change base class (pojo) as it introduce reference to new class. is it sustainable as i have to edit my base class for every new entry (which depends on base class).
Upvotes: 0
Views: 68
Reputation: 9786
Your code is violating the Open-Closed
principle, which says that your code should be open to extension but closed to modification, but in your case as you extend the functionalities you are also required to make some modification to the base entity. Probably this comes from the fact that you violated also another principle, namely the DIP(Dependence Inversion)
principle, which says that instead of depending on implementations you should depend on abstractions (interface
or abstract class
). Anyway you may want to consult the SOLID principles used in OOP design.
Upvotes: 2