It seems that MySQL and PostgreSQL act differently if null values are provided for default (defined in the db) columns on insert: the former uses the default whereas the latter inserts the null.
This is a problem for reveng-generated classes because a
.save() passes all columns to an insert including the null ones.
On looking for a solution I found the suggestion of
@Column(insertable = false)
but reveng doesn’t set that.
Does that sound like the correct solution?
Is there a reason reveng doesn’t do it already?
Would it be straightforward to add it, assuming the metadata contains default information?
Even then I’m not sure if this would want to be applied globally, nobody would ever be able to set any default columns on insert.
You could also use @DynamicInsert to address DEFAULT column issues.
Thanks, that looks good, but I can’t find a global setting for it and I can’t see a way to ask reveng to add the annotation to its generated classes?
There’s no such setting. However, you can either add it manually to all entities, or automate the task using the IDE Replace feature or
Thanks. We use reveng as part of our CI build so it can’t be a manual tweak.
It doesn’t look to be too hard to add it to the reveng code if this is a thing others might want too?
It should not be default though, so where best to put a configuration switch? A meta attribute in
You can send a Pull Request with this change in place so we can review it.
OK. Where’s the best place to discuss the right way to do things beforehand?
For example, the configuration question.
BasicColumnProcessor.java has reading the default value commented out with
TODO: only read if have a way to avoid issues with clobs/lobs and similar
@Koen_Aers is the right person to discuss this further.