Microsoft SQL Server, column in database is defined as NVARCHAR, but in Java code defined as @Column(name = "Column_Name", columnDefinition = "VARCHAR").
Hibernate fails with validation error below:
Caused by: org.hibernate.tool.schema.spi.SchemaManagementException: Schema-validation: wrong column type encountered in column [Column_Name] in table [Table_Name]; found [nvarchar (Types#NVARCHAR)], but expecting [varchar (Types#VARCHAR)] at org.hibernate.tool.schema.internal.SchemaValidatorImpl.validateColumnType(SchemaValidatorImpl.java:105) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
That would be no surprise, but reverse way (database VARCHAR, code NVARCHAR) does pass without errors.
This sounds illogical, I think that VARCHAR definition in code with NVARCHAR in database could work because there is no expected Unicode data loss, and NVARCHAR in code with VARCHAR in database should be validation error because that way there can be Unicode data loss.
Is there a reason for such strange validation behavior?