I know there are plenty of these questions here on SO and also on the net, but all the answers suggest using columnDefinition
which is database specific and hence not applicable for me because the system I'm working on needs to run on different databases.
I found this hibernate issue where someone requested this feature for annotations. The issue has been closed saying that another issue will cover that functionality. The second issue apparently added annotation @Generated
and also some others, but I couldn't find any documentation on how to define the default column value with those new annotations.
So my question is: Does anyone know how can I define a default column value with annotations (and NOT using columnDefinition
)?
Edit: to further clarify my problem: When I add a new not null column, I need Hibernate to update the existing schema (add the new column to the respective table). But since the column is non null, the database cannot create the column without specifying the default value (if there are already some rows in the table). So I need to instruct Hibernate to issue the following DDL statement: ALTER TABLE my_table ADD COLUMN new_column VARCHAR(3) DEFAULT 'def'
, but it has to be independent of the used database.