I have to enhance & extend an existing application which has its persistence layer built using JPA/Hibernate. The core entities of the persistence layer needs to be left untouched i.e. no option of changing the POJOs. But, the table structure will be modified by adding new columns.
I am contemplating extending the existing POJOs and implementing Inheritance mapping. Is this the best approach? Are there other approaches (possibly better) for handling this requirement?
Asked
Active
Viewed 110 times
0

Prakash
- 461
- 1
- 5
- 21
1 Answers
0
If there were no discriminator column in the target table then I guess you could still do it using the (non-JPA compliant) Hibernate annotation @DiscriminatorFormula.
http://docs.jboss.org/hibernate/annotations/3.5/reference/en/html_single/
The JPA spec also allows for overriding/disabling JPA annotation processing via XML mapping files. I haven't really used this feature however see the following discussion which appears to suggest that you could convert the existing Entity to a MappedSuperclass via this mechanism.