Reputation: 1229
Please bear with me. I am trying to unravel a mystery I've seen in last few days.
I have a following scenario. I have a table named "Bar" with three columns as "A", "B", and "C" in oracle DB. Please refer to figure 1.
I deployed new DDL changing its data structure so that it has columns as "A" and "D" (dropping "B" and "C"). Please refer to figure 2.
Now I have a web application (JSF + Spring Data JPA + Hibernate) that has java entity domain object called "Bar.java" which maps to the table "Bar". However this entity model's fields are not updated yet. It still has "A","B" and "C" fields (columns). If I deployed the application to an app server (e.g. weblogic), would hibernate framework alter the actual table by adding back "A","B" and "C" columns back? Please refer to figure 3.
Figure 1.
+-----------+
| A | B | C |
+-----------+
Figure 2.
+-------+
| A | D |
+-------+
Figure 3.
+---------------+
| A | B | C | D |
+---------------+
In a shop where I am, there are multiple developers are working together and some times their local working branch does not have others' latest commits. I am in the process of investigating why the table "Bar" is keep getting altered. Let's say I verified the table is in figure 2. state yesterday but today morning it is switched to figure 3.
My guess is some of the developers working branch still has old entity model and he/she not aware of it, works on their part of code, deploys the app and the table is altered and exception is thrown in the app server.
Can someone validate this assumption?
[update]
John Bollinger ans sbjavateam were right. I found a xml (not persistence.xml) that contains hibernate.hbm2ddl.auto = update which in turn updates a table.
Upvotes: 0
Views: 789
Reputation: 5407
hibernate has config option hibernate.hbm2ddl.auto with list of possible options :
validate: validate the schema, makes no changes to the database.
update: update the schema.
create: creates the schema, destroying previous data.
create-drop: drop the schema when the SessionFactory is closed explicitly, typically when the application is stopped.
somebody can run appilcation with hibernate.hbm2ddl.auto=update and all columnts(tables) will be added
Upvotes: 2