Reputation: 2325
Will adding an extra column in DB break hibernate?
Upvotes: 3
Views: 1986
Reputation: 425083
It will be OK as long as the column is not defined as NOT NULL
, or has a DEFAULT
value defined.
Insert statements that Hibernate issues will not provide a value for the column (obviously), but the statements it produces will be syntactically correct, even if it doesn't know about the column - the column and its value simply won't be mentioned in the insert statement.
You may consider using a database trigger to maintain values in that column if they must be derived in some special way, although would caution using database kung fu unless it's absolutely necessary, for example if you don't have control over the source code for the hibernate entity classes and the column must be some particular value that couldn't be declared as a column default.
Update and select statements would require no special treatment.
Upvotes: 5
Reputation: 33
If you mean by auto updating the tables by hibernate, then you can use the following in the hibernate configuration file
<property name="hbm2ddl.auto">create</property>
Upvotes: 0