MoSaleh
MoSaleh

Reputation: 33

@Nationalized probably not working with Hibernate Envers audit

I am using Spring Boot with Hibernate Envers to manage audit tables in a SQL Server database.

To optimize performance and handle non-Unicode strings properly, I updated my SQL Server connection string as follows:

spring.datasource.url=jdbc:sqlserver://localhost:1433;databaseName=mydb;sendStringParametersAsUnicode=false

In my entities, I use @Nationalized annotations to ensure string fields are stored as NVARCHAR in the database:

@Entity
@Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED)
public class MyEntity {
    ... other fields
    @Nationalized
    private String myField;
}

In the database, all fields in my audit tables (created by Hibernate Envers) are defined as NVARCHAR.

The problem is: When a field in the entity contains non-English characters (e.g., Arabic or Chinese), it is saved correctly in the main table. However, in the audit tables managed by Hibernate Envers, the non-English characters are replaced with question marks (???).

Upvotes: 1

Views: 28

Answers (0)

Related Questions