Hi all,
I'm working on a project using a relational database with a dynamic schema, i.e. columns can be added to tables at runtime. We're using plain SQL with JDBC now, but we're trying to switch to a more object-oriented approach and JPA. Is it possible to handle such schema changes with Hibernate?
I can imagine how I would create a new configuration and provide it to the application dynamically, my concern is how I can deal with object mapping afterwards. In other words, objects are mapped to tables and their attributes are mapped to columns. Arbitrary columns can be added (i.e. there is no way to determine how many of them and what their type would be before the application is started), hence the approach of having multiple classes reflecting several possible changes in the schema would not work. How can I "update" an object to be aware of additional columns if they appear? What I'm thinking of is having e.g. an object with a map as its attribute and I'm wondering if it's possible to map the values from that map to columns in a table somehow.
I would like to steer the discussion away from whether this is a good design - it's a decision that was made in the past due to performance reasons (having such a flat database improved performance dramatically) and changing it now is not an option.
Thanks, any advice is greatly appreciated!
|