Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
Hibernate 3.1.3
Hello, people
I have a question related to the mapping of two tables, A and B, which have the almost the same columns (table B has all the columns of table A plus one column of it's own). Table A represents some of the application data, table B represents temporary data.
Starting from this point I want to create a hibernate mapping (hbm files) to have mapped this two tables but to not duplicate the mapping code (and also to not have duplicate code inside the generated POJOs). It would be nice that the generated B bean can use the A bean's properties.
Also i must mention that these two tables
can't be related one to the other (no foreign key can be created between these two tables).
I tried first with
union-subclass by subclassing B from A, and if i have in B a record from A with the same ID, but with different data, when i try to load this record from B, Hibernate throws and error : duplicate data in session having the same identifier (B beeing derived from A).
I cannot solve this problem using
joined-subclass because no foreign keys can de defined between these tables.
For now the problem is solved through the existence of separate beans (A and B), but I got duplicated code.
There can be another solution or just maybe is bad DB tables design?
Can anybody help me in this issue?
Thank you
Daniel