I am currently building a e-commerce website using spring mvc4 hibernate4 and Mysql where the Admin should be able to dynamically add a column to a particular table when the application is already running and the server should not be restarted.For example if a new value is inserted in table 1 then a column should be created for it in table 2.
- Is there any way to configure hibernate 4 with JPA to dynamically add a column at runtime?
- And if yes can you give me a sample code?
- And if no what are the alternate ways of achieving my goal of dynamically adding columns?
I think there can be no JPA/Hibernate solution for this, since your Entities map to your database schema and what you are trying to achieve is simultanously mutating your Entity's Class and the corresponding schema. You need to go with JDBC and plain SQL for this and use DDL statements.
I wonder what's your use case for this?