I am working on database with JPA and i am curios about altering the database design. Lets say i have a table and i want to add/remove a column in that table.
I have tried with re-deploying technique but it did not work for me. I am using JPA 2.0
So, just want to know is there any standard way to alter database tables or manually add/remove table's design? Also is it possible to change the primary key of table ?
Any help will be highly appreciated.
Thanks :)
For non-production DBs you can use the persistence.xml
properties to either create, drop-create or just update the existing db schema (example for Hibernate):
<persistence ...>
<persistence-unit ...>
<property name="hibernate.hbm2ddl.auto" value="create-drop" />
for EclipseLink, the property name is different and so are the available options:
<property name="eclipselink.ddl-generation" value="create-tables"/>
<property name="eclipselink.ddl-generation.output-mode" value="database"/>
For production DBs however I would stick to manual changes as you have to be very careful about the details and the timing.