I have some 10 tables with the following schema
- ID
- Year
- Code
- Section
- Period
- Date
- Status
Each table has a name data_1, data_2 and so on. Now I want to write Hibernate mapping for these tables. As all these tables have the same schema with only the names different I wrote a POJO file with data as super class and all the other 10 classes inheriting it.
What do I do now with the hbm files? Do I have to write one hbm file for each table? I tried the union-subclass, but somehow I couldn’t get it right. I am getting a lot of unexplained errors in Hibernate.
How can I write the Hibernate mapping in this type of scenario? I am a starter in Hibernate and please note that the choice of database design is not in my hands. I have 30 such similar type of hierarchies.
First you must understand that there is no such thing as inheritance in relational database system. But there are strategies to map the inheritance structure to the database.
Check out the hibernate documentation at http://docs.jboss.org/hibernate/core/3.3/reference/en/html/inheritance.html
As far as I understand, your strategy is “Table per concrete class”