Kai Zander (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiMWMzMWRiNGY0...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-16253?atlOrigin=eyJpIjoiMWMzMW...
) HHH-16253 (
https://hibernate.atlassian.net/browse/HHH-16253?atlOrigin=eyJpIjoiMWMzMW...
) [Envers] Schema Validation Failure With Audited (N)Clob Column with Hibernate 6 on H2 (
https://hibernate.atlassian.net/browse/HHH-16253?atlOrigin=eyJpIjoiMWMzMW...
)
Issue Type: Bug Affects Versions: 6.0.0, 6.1.7 Assignee: Chris Cranford (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) Attachments: reproducers.zip Components: hibernate-core, hibernate-envers Created:
04/Mar/2023 03:22 AM Priority: Major Reporter: Kai Zander (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
)
Starting with Hibernate 6 (reproducible with 6.0.0-6.1.7), schema validation fails during
startup if an audited entity has a CLOB/NCLOB column. The schema validation complains
about the type of the CLOB/NCLOB column in the audit table.
Given the following entity:
@Entity
@Audited
class TestEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Lob
@Column(columnDefinition = "nclob" )
private String nclobColumn;
}
and the following Liquibase change set:
<changeSet id= "setup schema" author= "me" >
<createTable tableName= "revinfo" >
<column name= "rev" type= "int" autoIncrement=
"true" >
<constraints primaryKey= "true" primaryKeyName=
"pk_revinfo" />
</column>
<column name= "revtstmp" type= "bigint" >
<constraints nullable= "false" />
</column>
</createTable>
<createTable tableName= "test_entity" >
<column name= "id" type= "bigint" autoIncrement=
"true" >
<constraints primaryKey= "true" primaryKeyName=
"pk_test_entity" />
</column>
<column name= "nclob_column" type= "nclob" />
</createTable>
<createTable tableName= "test_entity_aud" >
<column name= "id" type= "bigint" >
<constraints primaryKey= "true" primaryKeyName=
"pk_test_entity_aud" />
</column>
<column name= "rev" type= "int" >
<constraints primaryKey= "true"
primaryKeyName= "pk_test_entity_aud"
referencedTableName= "revinfo"
referencedColumnNames= "rev"
foreignKeyName= "fk_test_entity_aud_rev_revinfo_rev"
/>
</column>
<column name= "revtype" type= "tinyint" >
<constraints nullable= "false" />
</column>
<column name= "nclob_column" type= "nclob" />
</createTable>
</changeSet>
And hibernate.hbm2ddl.auto=validate , schema validation fails with the following
exception:
org.hibernate.tool.schema.spi.SchemaManagementException: Schema-validation: wrong column
type encountered in column [nclob_column] in table [test_entity_aud]; found [character
(Types#CLOB)], but expecting [nclob (Types#VARCHAR)]
The exact same setup works on 5.6.15.
In
reproducers.zip (
https://hibernate.atlassian.net/secure/attachment/50240/50240_reproducers... )
I have attached two example projects. Both are identical Spring Boot projects, one with
Spring Boot 2.7.9 and Hibernate 5, the other with Spring Boot 3.0.4 and Hibernate 6. Both
projects use the same Liquibase (4.18.0) and H2 (2.1.214) versions. Extract them and run
$ ./mvnw spring-boot:run
The Hibernate 5 project starts and shuts down correctly, the Hibernate 6 project fails
with the above mentioned schema validation error.
The same error can be reproduced in Hibernate 5 by removing the @Lob annotation from the
nclobColumn attribute. Maybe Hibernate/Envers 6 have issues with that annotation?
Whether @Lob is present or not does not make a difference in Hibernate 6, the error is
raised in both scenarios.
(
https://hibernate.atlassian.net/browse/HHH-16253#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16253#add-comment?atlOrigin=ey...
)
Get Jira notifications on your phone! Download the Jira Cloud app for Android (
https://play.google.com/store/apps/details?id=com.atlassian.android.jira....
) or iOS (
https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=Em...
) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100217- sha1:65be9f2 )