MySQL and MariaDB
On MySQL 5.7+ and MariaDB 10.2+ temporal columns are now created as DATETIME(6) and TIME(6) (DateFractionDigits=6) instead of whole-second precision, so that @Version attributes of type Instant or LocalDateTime can distinguish updates within the same second.
The value is set at connection time and overrides a DateFractionDigits value given in openjpa.jdbc.DBDictionary.
Existing columns keep working, but schema validation or refresh may report or alter the precision.
Use @Column(secondPrecision=0) on individual columns, or subclass the dictionary and reset dateFractionDigits after connectedConfiguration(), to keep whole seconds.
MariaDBDictionary no longer replaces a configured positive openjpa.FetchBatchSize with Integer.MIN_VALUE (the Connector/J 2.x streaming mode); the configured value is passed to the driver unchanged. MySQLDictionary keeps the streaming behavior.
Subclass MariaDBDictionary and override getBatchFetchSize(int) to restore streaming.
MariaDB 10.3 introduced sequence objects, and MariaDBDictionary now reports sequence support on 10.3 and later, where it previously declared none.
A @SequenceGenerator is therefore backed by a real sequence, so the schema tool issues CREATE SEQUENCE and DROP SEQUENCE for it and the database user needs the privilege to do so.
The sequences are created NOCACHE, because OpenJPA caches values itself in blocks of the generator’s allocation size, and the server-side cache of 1000 increments - 1000 times the allocation size in identifiers, which is 50000 for an allocationSize of 50 - would only add gaps, since the ALTER SEQUENCE … INCREMENT BY that OpenJPA issues per sequence instance discards the rest of the cached range.
MariaDB 10.2 and earlier keep the sequence table fallback described in @SequenceGenerator on a database without sequences; a NextSequenceQuery configured in openjpa.jdbc.DBDictionary is left untouched.
EXTRACT(WEEK FROM …) now returns the ISO week, as the specification defines it, by rendering WEEK(x, 3).
Before, MySQL and MariaDB computed it with weeks starting on Sunday, so queries on such dates return different values: for example 2024-01-01 is now week 1 instead of 0, and 2023-12-31 is week 52 instead of 53.
A configured ExtractDateTimeFieldFunction no longer applies to WEEK on these databases.
EXTRACT(SECOND FROM …) now includes the fraction of the second, as the specification requires, by adding EXTRACT(MICROSECOND FROM …) / 1000000.0 to the whole seconds that MySQL and MariaDB return.
A LocalTime (and so an OffsetTime) is now passed to and read from the driver as such instead of as a java.sql.Time, which has no fraction of a second, so its fraction is kept in parameters and in TIME(6) columns.
On MariaDB before 11.1, a bulk update or delete whose WHERE clause has a subquery on the target table now matches the primary keys of the affected rows in a derived table, as on MySQL (AllowsBulkTargetInSubselect=false), because these servers reject the multi-table DELETE that OpenJPA generates for it.
Since the version is now parsed from the server’s reply even when a driver that is not MariaDB aware passes it on with its 5.5.5- replication compatibility prefix, such a deployment reaches the features gated on 10.2 as well: temporal columns are generated as DATETIME(6) rather than DATETIME, as they already were for the same server reached through mariadb-java-client.
A schema created by an earlier release keeps whole-second DATETIME columns until they are altered, and reading them is unaffected.
The version gate assigns timestampTypeName and dateFractionDigits outright, so a value configured in openjpa.jdbc.DBDictionary does not survive it; subclass MariaDBDictionary to generate the previous types.
There is no upgrade path from an earlier release to migrate: a named @SequenceGenerator failed outright on every MariaDB before 4.2.0, so no counter exists to move.
The case that needs care is a server upgrade under 4.2.0.
An application that ran on MariaDB 10.2 or earlier has its counters in OPENJPA_SEQUENCES_TABLE; once the server is 10.3 or later the same generator is backed by a sequence object, which openjpa.jdbc.SynchronizeMappings or the schema tool creates starting at the generator’s initialValue and which therefore hands out identifiers that are already in use.
Before upgrading the server, either create each sequence with START WITH above the highest identifier in use, or keep the existing counter by declaring the generator’s sequenceName as a value-table(PrimaryKeyValue=…) plugin string, which @SequenceGenerator on a database without sequences leaves alone.
Emptying the dictionary’s NextSequenceQuery does not pin the old backing store, because an empty value is normalised to none and then set again for a 10.3 server.