{"record":{"id":"48af788a6264c97c","repo":"hibernate/hibernate-orm","slug":"cannot-convert-changeset-timestamp-to-instant-va","errorCode":null,"errorMessage":"Cannot convert changeset timestamp to Instant: <value>","messagePattern":"Cannot convert changeset timestamp to Instant: <value>","errorType":"exception","errorClass":"AuditException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/audit/internal/AuditLogImpl.java","lineNumber":467,"sourceCode":"\t\t\t);\n\t\t}\n\t\treturn persister.getEntityName();\n\t}\n\n\tprivate static Instant toInstant(Object value) {\n\t\tif ( value instanceof Instant instant ) {\n\t\t\treturn instant;\n\t\t}\n\t\telse if ( value instanceof LocalDateTime localDateTime ) {\n\t\t\treturn localDateTime.atZone( ZoneId.systemDefault() ).toInstant();\n\t\t}\n\t\telse if ( value instanceof Date date ) {\n\t\t\treturn date.toInstant();\n\t\t}\n\t\telse if ( value instanceof Long millis ) {\n\t\t\treturn Instant.ofEpochMilli( millis );\n\t\t}\n\t\tthrow new AuditException( \"Cannot convert changeset timestamp to Instant: \" + value );\n\t}\n}\n","sourceCodeStart":449,"sourceCodeEnd":470,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/audit/internal/AuditLogImpl.java#L449-L470","documentation":"AuditLog converts changelog timestamp values to java.time.Instant with a fixed chain: Instant as-is, LocalDateTime via the system zone, java.util.Date via toInstant(), Long as epoch millis. Any other runtime type - LocalDate, OffsetDateTime, java.sql.Timestamp, or a custom user type - falls through the chain and AuditException('Cannot convert changeset timestamp to Instant: <value>') is thrown.","triggerScenarios":"Declaring the @Changelog.Timestamp property with a type outside the supported set (e.g. LocalDate or a converted custom type) and then calling a timestamp-returning API such as getChangesetTimestamp.","commonSituations":"Date-only changelog fields modeled as LocalDate; joda-style or custom AttributeConverter types; java.sql.Timestamp fields on legacy changelog entities.","solutions":["Change the changelog timestamp property to Instant, LocalDateTime, java.util.Date, or Long (epoch millis).","If the exotic type must stay, query the changelog entity yourself and convert the value in application code."],"exampleFix":"// before\n@Changelog.Timestamp\nLocalDate changeDate; // unsupported by AuditLog conversion\n// after\n@Changelog.Timestamp\nInstant changedAt;","handlingStrategy":"validation","validationCode":"// fail fast at bootstrap when the changelog timestamp type is unsupported\nField f = RevEntity.class.getDeclaredField(\"changedAt\");\nClass<?> t = f.getType();\nif (!(t == Instant.class || t == LocalDateTime.class || t == Date.class || t == Long.class)) {\n    throw new IllegalStateException(\"Unsupported @Changelog.Timestamp type: \" + t);\n}","typeGuard":"static boolean supportedTimestampType(Class<?> t) {\n    return t == Instant.class || t == LocalDateTime.class\n        || t == Date.class || t == Long.class || t == long.class;\n}","tryCatchPattern":null,"preventionTips":["Use Instant (or one of Date/LocalDateTime/epoch-millis) for changelog timestamp fields","Add a mapping test that instantiates the changelog and round-trips a timestamp via AuditLog"],"tags":["hibernate","audit","timestamp","type-conversion","changelog"],"backgroundTag":"unsupported-timestamp-type","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}