Skip to content

Commit fc53d8b

Browse files
authored
Fix non-portable BLOB columnDefinition in WebAuthnCredential (#275)
* fix: Remove non-portable BLOB columnDefinition from WebAuthnCredential Remove hardcoded `columnDefinition = "BLOB"` from three byte[] fields in WebAuthnCredential. The `@Lob` annotation already handles dialect- appropriate type mapping (BLOB for MySQL, bytea for PostgreSQL, etc.). The explicit columnDefinition bypassed Hibernate's dialect translation, causing DDL failures on PostgreSQL and other non-MySQL databases. Fixes #274 * fix: Use plain byte[] instead of @lob for portable WebAuthn columns Replace `@Lob @column(columnDefinition = "BLOB")` with plain `byte[]` and explicit `@Column(length = ...)` on the three binary fields in WebAuthnCredential. `@Lob` on byte[] in Hibernate 7 generates literal `blob` in DDL, which bypasses dialect translation and fails on PostgreSQL (no `blob` type). Plain byte[] lets each dialect choose the correct native type: `bytea` on PostgreSQL, `varbinary`/`mediumblob` on MySQL. Verified DDL generation against a real PostgreSQL 16 instance and confirmed all three columns map to `bytea`. Full H2 test suite passes with no regressions. Fixes #274
1 parent 9197e84 commit fc53d8b

1 file changed

Lines changed: 3 additions & 7 deletions

File tree

src/main/java/com/digitalsanctuary/spring/user/persistence/model/WebAuthnCredential.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import jakarta.persistence.FetchType;
77
import jakarta.persistence.Id;
88
import jakarta.persistence.JoinColumn;
9-
import jakarta.persistence.Lob;
109
import jakarta.persistence.ManyToOne;
1110
import jakarta.persistence.Table;
1211
import lombok.Data;
@@ -31,8 +30,7 @@ public class WebAuthnCredential {
3130
private WebAuthnUserEntity userEntity;
3231

3332
/** COSE-encoded public key (typically 77-300 bytes, RSA keys can be larger). */
34-
@Lob
35-
@Column(name = "public_key", nullable = false, columnDefinition = "BLOB")
33+
@Column(name = "public_key", nullable = false, length = 2048)
3634
private byte[] publicKey;
3735

3836
/** Counter to detect cloned authenticators. */
@@ -60,13 +58,11 @@ public class WebAuthnCredential {
6058
private boolean backupState;
6159

6260
/** Attestation data from registration (can be several KB). */
63-
@Lob
64-
@Column(name = "attestation_object", columnDefinition = "BLOB")
61+
@Column(name = "attestation_object", length = 65536)
6562
private byte[] attestationObject;
6663

6764
/** Client data JSON from registration (can be several KB). */
68-
@Lob
69-
@Column(name = "attestation_client_data_json", columnDefinition = "BLOB")
65+
@Column(name = "attestation_client_data_json", length = 65536)
7066
private byte[] attestationClientDataJson;
7167

7268
/** Creation timestamp. */

0 commit comments

Comments
 (0)