I have to map a lecagy database for read-only purposes that contains the following structure:
Table MAIN:
id productId productType
Table PRODUCT_A:
id description_a
Table PRODUCT_B:
id description_b
Table PRODUCT_C:
id description_c
Depending on the value in column productTyp, the productId refers either to the PRODUCT_A,PRODUCT_B, or PRODUCT_C.
For each of the tables I create a Java entity. The Main class contains one collection for each product.
The products are not in a ‘is a’ relationship with the main class. It is used under other circumstance as independent entity.
Is there any way to map this using hbm.xml files?
The proper way to map this is via
<any>:You’ll have to map the appropriate
ProductAetc… classes to corresponding tables (perhaps you already have).