The problem
Dynamically add and remove fields to entities on the fly using Hibernate.
I m sure this is a common scenario, most enterprise applications will require some level of customization. so what is the best way to do it? also ideally it should not require a recompile and smoothly create/remove the field in the schema and allow the application to continue working.
If its just a question of updating the xml, ( i m pretty sure the proxy classes are required) then how does the schema gets reloaded?
Thanks a million for input
Note: If you think there is a better solution I m also all ears thanks
I don’t think it’s a very common use case and as Aaron suggests it’s going to take you quite a while to nail this down.
The schema update will not be straightforward either. Even thought Hibernate does offer programmatic schema changes, it’s limited to simple things like adding/removing fields. That might work for you, but if the data type or nullability of a column changes, Hibernate won’t update it for you.
You may want to consider a OneToMany relationship and store the data as a row in a separate table, assuming you can accept the overhead of another join.