Skip to content

[OPENJPA-3028] Store chars as CHAR by default on Oracle - #277

Merged
solomax merged 1 commit into
masterfrom
OPENJPA-3028-oracle-char
Nov 7, 2026
Merged

solomax merged 1 commit into
masterfrom
OPENJPA-3028-oracle-char

Conversation

@rzo1

@rzo1 rzo1 commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Oracle stored char/Character as NUMBER, which fails against CHAR(1) columns such as those in the TCK schema (ORA-12899). Oracle now defaults to StoreCharsAsNumbers=false like the other dictionaries. Generated columns are CHAR(1 CHAR), so non-ASCII chars fit. Existing NUMBER schemas need StoreCharsAsNumbers=true (see migration notes).

Oracle TCK: +100 passing tests, no regressions.

OracleDictionary still stored char and Character attributes as NUMBER
code points, so writing them into a pre-existing CHAR(1) column, such as
the ones of the Jakarta Persistence TCK schema, failed with ORA-12899
(the code point '97' is two characters). Oracle has a CHAR type, so use
the same default as Derby, H2, MySQL, MariaDB, SQL Server and PostgreSQL;
an explicit StoreCharsAsNumbers=true is still respected.

Oracle sizes columns in bytes by default (NLS_LENGTH_SEMANTICS=BYTE), so a
generated CHAR(1) column of an AL32UTF8 database would reject any
non-ASCII character, e.g. 'é' or '€', with ORA-12899. The generated column
of a char or Character attribute is therefore declared with character
length semantics, CHAR(1 CHAR), and holds every character the NUMBER
mapping could hold.

Behaviour change: schemas created by earlier releases on Oracle hold such
attributes in NUMBER columns and need StoreCharsAsNumbers=true (or a
migration to CHAR(1 CHAR)); newly generated columns are CHAR(1 CHAR). A
pre-existing byte sized CHAR(1) column only holds single-byte characters.
The migration notes and the StoreCharsAsNumbers reference say so.

TestStoreCharsAsNumbersDefaults covers the Oracle default and the
generated type name. TestCharStorage checks the default, round-trips
non-ASCII characters and, on Oracle only, accepts the NUMBER type Oracle
reports for integer columns.
@rzo1
rzo1 requested review from cristof and solomax November 6, 2026 14:16
@solomax
solomax merged commit 48bc52e into master Nov 7, 2026
4 checks passed
@solomax
solomax deleted the OPENJPA-3028-oracle-char branch November 7, 2026 03:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants