3

Will adding an extra column in DB break hibernate?

2 Answers 2

5

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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> 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.