Avoid insert 'null' values to database table via JPA

Using the annotation

@Column(insertable = false)

will prevent the value being generated in the sql.


I would not rely on default values in the database in conjunction with JPA. You would have to read the entity back after the insert otherwise you have a mismatch between the entity state and the db state.

Choose the pragmatic approach here and initialise all values in java. Never heard of a way to tell JPA/Hibernate to leave out null values in an insert/update.