From 7bd80a7eda4a1357b1d257a97f10637da6ce5de2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Kraus?= Date: Wed, 29 Nov 2023 18:12:37 +0100 Subject: [PATCH] jakartaee/persistence#431 - add SchemaManager Initial implementation. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomáš Kraus --- .../config/PersistenceUnitProperties.java | 45 +- .../databaseaccess/DatabasePlatform.java | 33 +- .../databaseaccess/FieldTypeDefinition.java | 108 ++++- .../i18n/ExceptionLocalizationResource.java | 10 +- .../i18n/LoggingLocalizationResource.java | 8 + .../platform/database/HANAPlatform.java | 2 +- .../platform/database/MySQLPlatform.java | 4 +- .../coordination/MetadataRefreshListener.java | 4 +- .../schemaframework/FieldDefinition.java | 49 +- .../tools/schemaframework/SchemaManager.java | 52 +- .../tools/schemaframework/TableCreator.java | 459 +++++++++++++++--- .../schemaframework/TableDefinition.java | 35 +- .../TableValidationException.java | 379 +++++++++++++++ .../Persistence32TableCreator.java | 83 ---- .../main/resources/META-INF/persistence.xml | 28 +- .../jpa/persistence32/AbstractPokemon.java | 92 +--- .../persistence32/AbstractSchemaManager.java | 130 +++++ .../jpa/persistence32/AbstractSuite.java | 134 +++++ .../persistence32/CriteriaBuilderTest.java | 94 ++-- .../DatabaseActionVerifyTest.java | 55 +++ .../EntityManagerFactoryTest.java | 3 + .../tests/jpa/persistence32/QueryTest.java | 13 +- .../SchemaManagerCreateTest.java | 62 +++ .../persistence32/SchemaManagerDropTest.java | 101 ++++ .../SchemaManagerTruncateOnExistingTest.java | 74 +++ ...emaManagerValidateOnMissingColumnTest.java | 113 +++++ ...emaManagerValidateOnMissingSchemaTest.java | 77 +++ ...maManagerValidateOnModifiedColumnTest.java | 101 ++++ ...emaManagerValidateOnSurplusColumnTest.java | 120 +++++ ...chemaManagerValidateOnValidSchemaTest.java | 50 ++ .../persistence32/UnionCriteriaQueryTest.java | 45 +- .../jpa/EntityManagerFactoryDelegate.java | 11 +- .../internal/jpa/EntityManagerSetupImpl.java | 217 ++++++--- .../internal/jpa/SchemaManagerImpl.java | 81 ++++ .../internal/jpa/ValidationFailure.java | 54 +++ 35 files changed, 2510 insertions(+), 416 deletions(-) create mode 100644 foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/tools/schemaframework/TableValidationException.java delete mode 100644 jpa/eclipselink.jpa.testapps/jpa.test.persistence32/src/main/java/org/eclipse/persistence/testing/models/jpa/persistence32/Persistence32TableCreator.java create mode 100644 jpa/eclipselink.jpa.testapps/jpa.test.persistence32/src/test/java/org/eclipse/persistence/testing/tests/jpa/persistence32/AbstractSchemaManager.java create mode 100644 jpa/eclipselink.jpa.testapps/jpa.test.persistence32/src/test/java/org/eclipse/persistence/testing/tests/jpa/persistence32/AbstractSuite.java create mode 100644 jpa/eclipselink.jpa.testapps/jpa.test.persistence32/src/test/java/org/eclipse/persistence/testing/tests/jpa/persistence32/DatabaseActionVerifyTest.java create mode 100644 jpa/eclipselink.jpa.testapps/jpa.test.persistence32/src/test/java/org/eclipse/persistence/testing/tests/jpa/persistence32/SchemaManagerCreateTest.java create mode 100644 jpa/eclipselink.jpa.testapps/jpa.test.persistence32/src/test/java/org/eclipse/persistence/testing/tests/jpa/persistence32/SchemaManagerDropTest.java create mode 100644 jpa/eclipselink.jpa.testapps/jpa.test.persistence32/src/test/java/org/eclipse/persistence/testing/tests/jpa/persistence32/SchemaManagerTruncateOnExistingTest.java create mode 100644 jpa/eclipselink.jpa.testapps/jpa.test.persistence32/src/test/java/org/eclipse/persistence/testing/tests/jpa/persistence32/SchemaManagerValidateOnMissingColumnTest.java create mode 100644 jpa/eclipselink.jpa.testapps/jpa.test.persistence32/src/test/java/org/eclipse/persistence/testing/tests/jpa/persistence32/SchemaManagerValidateOnMissingSchemaTest.java create mode 100644 jpa/eclipselink.jpa.testapps/jpa.test.persistence32/src/test/java/org/eclipse/persistence/testing/tests/jpa/persistence32/SchemaManagerValidateOnModifiedColumnTest.java create mode 100644 jpa/eclipselink.jpa.testapps/jpa.test.persistence32/src/test/java/org/eclipse/persistence/testing/tests/jpa/persistence32/SchemaManagerValidateOnSurplusColumnTest.java create mode 100644 jpa/eclipselink.jpa.testapps/jpa.test.persistence32/src/test/java/org/eclipse/persistence/testing/tests/jpa/persistence32/SchemaManagerValidateOnValidSchemaTest.java create mode 100644 jpa/org.eclipse.persistence.jpa/src/main/java/org/eclipse/persistence/internal/jpa/SchemaManagerImpl.java create mode 100644 jpa/org.eclipse.persistence.jpa/src/main/java/org/eclipse/persistence/internal/jpa/ValidationFailure.java diff --git a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/config/PersistenceUnitProperties.java b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/config/PersistenceUnitProperties.java index a4484497e57..1ab80393f38 100644 --- a/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/config/PersistenceUnitProperties.java +++ b/foundation/org.eclipse.persistence.core/src/main/java/org/eclipse/persistence/config/PersistenceUnitProperties.java @@ -51,6 +51,8 @@ // - 533148 : Add the eclipselink.jpa.sql-call-deferral property // 12/06/2018 - Will Dazey // - 542491: Add new 'eclipselink.jdbc.force-bind-parameters' property to force enable binding +// 12/05/2023: Tomas Kraus +// - New Jakarta Persistence 3.2 Features package org.eclipse.persistence.config; import jakarta.persistence.EntityManager; @@ -2357,6 +2359,14 @@ public class PersistenceUnitProperties { */ public static final String SCHEMA_GENERATION_NONE_ACTION = "none"; + /** + * The parameter value "verify" + *

For use with the "jakarta.persistence.schema-generation.database.action" + * and "jakarta.persistence.schema-generation.scripts.action" properties.

+ *

Specifies that database tables should be verified.

+ */ + public static final String SCHEMA_GENERATION_VERIFY_ACTION = "verify"; + /** * The parameter value "metadata" *

For use with the "jakarta.persistence.schema-generation.create-source" @@ -3032,7 +3042,7 @@ public class PersistenceUnitProperties { * should be automatically generated for foreign key constraints. It is normally recommended to have * an index for a foreign key. *

- * By default indexes are not generated, most database also do not auto generate indexes, although some do. + * By default, indexes are not generated, most database also do not auto generate indexes, although some do. *

* Allowed Values: *