columnDefinition broken for audit mappings
should be fixed with version 5.4.11, but now a column definition like
@Column(name = "text", columnDefinition = "mediumtext")
private String text;
@Column(name = "foo", columnDefinition = "char(40)")
private String foo;
no longer works with envers. It will result in the following log messages
> Column [text] uses a column-definition of [mediumtext], resolved sql-type as [varchar(255)].
> Column [foo] uses a column-definition of [char(40)], resolved sql-type as [varchar(255)].
and exceptions like this:
> Schema-validation: wrong column type encountered in column [foo] in table [bar]; found [char (Types#CHAR)], but expecting [varchar(255) (Types#VARCHAR)]
I think this behaviour was added by this commit: https://github.com/hibernate/hibernate-orm/commit/38f01311602f115ccec23f9ee8faf4b2d69d636d
As I mentioned in HHH-13922, I believe the best course of action for now is to revert HHH-10844. By doing the revert, the audit tables will once again have their sql-type based specifically on the sql-type from the base table. For the situations mentioned in this issue, things will "just work".
The same applies with custom domain objects. Example:
And it generates varchar(255) instead of cs_key
This results in the application not been able to start anymore:
Schema-validation: wrong column type encountered in column [configuration_group_key] in table [configuration_group_aud]; found [cs_key (Types#DISTINCT)], but expecting [varchar(255) (Types#VARCHAR)]