rzo1 opened a new pull request, #303: URL: https://github.com/apache/openjpa/pull/303
[OPENJPA-3075](https://issues.apache.org/jira/browse/OPENJPA-3075): an entity named `Window` (or `Order`, `User`, ...) gives `CREATE TABLE Window`, which Derby rejects. **Reserved words.** The words Derby rejects as unquoted identifiers were measured on embedded Derby 10.16.1.1 (the version in the poms) with an unquoted `CREATE TABLE` per candidate word, about 1,080 candidates from Derby's parser tokens, its docs, the JDBC keywords, SQL:2016 and the word lists of all dictionaries. `DerbyDictionary` was missing 9 of them: `BIGINT`, `CURRENT_ROLE`, `CURSORS`, `DEFINER`, `DETERMINISTIC`, `GETCURRENTCONNECTION`, `INVOKER`, `WINDOW`, `XMLQUERY` (as column name only `CURSORS`). **Default table and sequence names.** JPA default table names (entity, join and collection tables) and default sequence names (`@SequenceGenerator` without `sequenceName`) never went through the dictionary, so the reserved words did not help there. A new `DBDictionary.getValidDefaultTableName` / `getValidDefaultSequenceName` makes such a name valid only if it is in the dictionary's set of words the database really rejects (`invalidTableWordSet`). Only `DerbyDictionary` fills that set, so e.g. `Window` becomes `WINDOW0` and its join table `WINDOW0_items`; words Derby accepts (`ACTION`, `COUNT`, `SESSION`, ...) stay unchanged. Explicit `@Table` / `sequenceName` values, delimited names and `DelimitIdentifiers=true` are not touched. **No compatibility flag:** every name that changes either fails on Derby today or is a join table of an entity whose own table fails today. A dump of the default names of 2,860 names (every reserved / invalid word of all dictionaries in three cases plus ordinary names) is byte-identical before and after for PostgreSQL, MySQL, MariaDB, Oracle, SQL Server, H2, HSQLDB and DB2; on Derby each changed name was checked to be rejected by Derby before the change. **Tests:** `TestDerbyDictionaryReservedWords`, `TestValidDefaultTableName`, `TestDefaultTableNames` and `TestReservedWordEntityNames` (entities `Window`, `Order`, `User` with join tables, element collections and a default sequence: DDL, persist, find, JPQL, bulk update; Derby only). The full `openjpa-persistence-jdbc` suite passes on Derby (4,116 tests); the dynamicschema, delimited identifiers, jdbc, embed and inheritance tests show no new failures on MySQL 8.4, MariaDB 12.3 and PostgreSQL 18. The TCK passed locally on Derby (2135 tests) before the default-name change. CI: the TCK and Databases workflows were started on this branch; this PR stays a draft until both pass. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
