0
I understand the concept of Heritage, currently I am working with a condo management project, and I find myself in the following question as you can see below;
Please disregard the Debts table, my problem in question is the Condomino, Sindico, Resident and Proprietary table. The Syndic, Resident and Proprietary are a type of Condo, because I know that if I had to put the same attributes that are in Condomino and put in Sindico, Resident and Proprietary would be redundant, that’s why I put Condomino as Super-Class and Sindico classes, Resident and Owner as Sub-Class, that is, Condomino will be abstract and the other classes below will inherit the attributes of the Condomino class.
I know how to abstract all this very well in UML, and I also know how to do it in Java, in all classes I put JPA annotations as an example of @Notblank, and I only put the @Id, @Generatedvalue annotation in Sub-Classes because the Condomino class is an abstract class.
The other thing I did was just put @Entity in the Sub-Classes for the same reason the Condomino class is an abstract class.
Is that how I did it? Will when you run the project it will create my tables all straight in the base?
If even with the description I did below it is necessary to put the code here in this post, do not worry that I put, but I think with the descriptions I did above can understand.
What kind of problems could I have if I were to implement inheritance in my tables?
– wladyband
By default it will not work, you will need additional settings. Here is a post on the subject in more detail: http://blog.caelum.com.br/jpa-com-hibernate-heranca-e-mappings/
– Shura16