This is an automated email from the ASF dual-hosted git repository.

pcristof pushed a commit to branch OPENJPA-2940
in repository https://gitbox.apache.org/repos/asf/openjpa.git

commit a9780a4bd0579b2fa600d84d9dba670c34ffb7f9
Author: Paulo Cristovão de Araújo Silva Filho <pcris...@gmail.com>
AuthorDate: Fri Jul 11 15:37:25 2025 -0300

    [OPENJPA-2940][WIP] Intermediate commit
    
    * Added XML JPA 3.2 schema and definitions
    * Added configuration support by 3.2 version
    * Added SchemaManager impl and corresponding methods in BrokerFactory
    interface
    * Added concrete working (not for h2-2) implementation of SchemaManager
    methods for JDBCBrokerFactory
    * Added concrete working impl for EMF#getName()
---
 .../openjpa/jdbc/kernel/JDBCBrokerFactory.java     |  41 ++-
 .../apache/openjpa/conf/SpecificationPlugin.java   |   2 +-
 .../openjpa/kernel/AbstractBrokerFactory.java      |  22 +-
 .../org/apache/openjpa/kernel/BrokerFactory.java   |  10 +
 .../openjpa/kernel/DelegatingBrokerFactory.java    |  38 ++
 .../apache/openjpa/lib/meta/XMLVersionParser.java  |   1 +
 .../org/apache/openjpa/conf/TestGetProperty.java   |   4 +
 .../openjpa/jdbc/meta/TestJDBCSchemaManager.java   | 114 ++++++
 .../org/apache/openjpa/jdbc/meta/UUIDEntity.java   |  41 +++
 .../persistence/EntityManagerFactoryImpl.java      |   7 +-
 .../persistence/PersistenceProductDerivation.java  |   9 +
 .../persistence/PersistenceProviderImpl.java       |  17 +-
 .../openjpa/persistence/SchemaManagerImpl.java     |  66 ++++
 .../openjpa/persistence/persistence_3_2.xsd.rsrc   | 383 +++++++++++++++++++++
 14 files changed, 739 insertions(+), 16 deletions(-)

diff --git 
a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCBrokerFactory.java
 
b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCBrokerFactory.java
index fe9baada6..e132ee2ee 100644
--- 
a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCBrokerFactory.java
+++ 
b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCBrokerFactory.java
@@ -38,12 +38,14 @@ import org.apache.openjpa.jdbc.meta.MappingTool;
 import org.apache.openjpa.jdbc.schema.SchemaTool;
 import org.apache.openjpa.kernel.AbstractBrokerFactory;
 import org.apache.openjpa.kernel.Bootstrap;
+import org.apache.openjpa.kernel.Broker;
 import org.apache.openjpa.kernel.BrokerImpl;
 import org.apache.openjpa.kernel.StoreManager;
 import org.apache.openjpa.lib.conf.ConfigurationProvider;
 import org.apache.openjpa.lib.conf.Configurations;
 import org.apache.openjpa.lib.util.Localizer;
 import org.apache.openjpa.lib.util.StringUtil;
+import org.apache.openjpa.util.OpenJPAException;
 import org.apache.openjpa.util.UserException;
 
 /**
@@ -139,14 +141,47 @@ public class JDBCBrokerFactory extends 
AbstractBrokerFactory {
             unlock();
         }
     }
+    
+    @Override
+    public void createPersistenceStructure(boolean createSchemas) {
+       JDBCConfiguration conf = (JDBCConfiguration) getConfiguration();
+       Broker broker = super.newBrokerImpl(conf.getConnectionUserName(), 
conf.getConnectionPassword());
+       String baseAction = createSchemas ? "createDB, add": 
MappingTool.ACTION_ADD;
+       synchronizeMappings(broker.getClassLoader(), conf, 
String.format("buildSchema(ForeignKeys=true,SchemaAction='%s')", baseAction));
+    }
+    
+    @Override
+    public void dropPersistenceStrucuture(boolean dropSchemas) {
+       JDBCConfiguration conf = (JDBCConfiguration) getConfiguration();
+       Broker broker = super.newBrokerImpl(conf.getConnectionUserName(), 
conf.getConnectionPassword());
+       String baseAction = dropSchemas ? "drop, dropDB": 
MappingTool.ACTION_DROP;
+       synchronizeMappings(broker.getClassLoader(), conf, 
String.format("buildSchema(ForeignKeys=true,SchemaAction='%s')", baseAction));
+    }
+    
+    @Override
+    public void validatePersistenceStruture() throws OpenJPAException {
+       JDBCConfiguration conf = (JDBCConfiguration) getConfiguration();
+       Broker broker = super.newBrokerImpl(conf.getConnectionUserName(), 
conf.getConnectionPassword());
+       synchronizeMappings(broker.getClassLoader(), conf, 
"buildSchema(ForeignKeys=true,SchemaAction='retain')");
+    }
+    
+    @Override
+    public void truncateData() {
+       JDBCConfiguration conf = (JDBCConfiguration) getConfiguration();
+       Broker broker = super.newBrokerImpl(conf.getConnectionUserName(), 
conf.getConnectionPassword());
+       String baseAction = "refresh,deleteTableContents";
+       synchronizeMappings(broker.getClassLoader(), conf, 
String.format("buildSchema(ForeignKeys=true,SchemaAction='%s')", baseAction));
+    }
+    
+    protected boolean synchronizeMappings(ClassLoader loader, 
JDBCConfiguration conf) {
+       return synchronizeMappings(loader, conf, conf.getSynchronizeMappings());
+    }
 
     /**
      * Synchronize the mappings of the classes listed in the configuration.
      */
-    protected boolean synchronizeMappings(ClassLoader loader,
-        JDBCConfiguration conf) {
+    protected boolean synchronizeMappings(ClassLoader loader, 
JDBCConfiguration conf, String action) {
         mapSchemaGenerationToSynchronizeMappings(conf);
-        String action = conf.getSynchronizeMappings();
         if (StringUtil.isEmpty(action))
             return false;
 
diff --git 
a/openjpa-kernel/src/main/java/org/apache/openjpa/conf/SpecificationPlugin.java 
b/openjpa-kernel/src/main/java/org/apache/openjpa/conf/SpecificationPlugin.java
index 3fe100fae..e39819c06 100644
--- 
a/openjpa-kernel/src/main/java/org/apache/openjpa/conf/SpecificationPlugin.java
+++ 
b/openjpa-kernel/src/main/java/org/apache/openjpa/conf/SpecificationPlugin.java
@@ -54,7 +54,7 @@ public class SpecificationPlugin extends ObjectValue 
implements ValueListener {
      *
      * @param str can be null to set the Specification to null.
      * If non-null, then the String must be in Specification format
-     * @see Specification#create(String)
+     * @see Specification#createPersistenceStructure(String)
      */
     @Override
     public void setString(String str) {
diff --git 
a/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AbstractBrokerFactory.java
 
b/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AbstractBrokerFactory.java
index 1c75231a7..c5bc52a15 100644
--- 
a/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AbstractBrokerFactory.java
+++ 
b/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AbstractBrokerFactory.java
@@ -469,6 +469,26 @@ public abstract class AbstractBrokerFactory implements 
BrokerFactory {
     public void unlock() {
         _lock.unlock();
     }
+    
+    @Override
+    public void createPersistenceStructure(boolean createSchemas) {
+       throw new UnsupportedOperationException();
+    }
+    
+    @Override
+    public void dropPersistenceStrucuture(boolean dropSchemas) {
+       throw new UnsupportedOperationException();
+    }
+    
+    @Override
+    public void validatePersistenceStruture() throws OpenJPAException {
+       throw new UnsupportedOperationException();
+    }
+    
+    @Override
+    public void truncateData() {
+       throw new UnsupportedOperationException();
+    }
 
     /**
      * Replaces the factory with this JVMs pooled version if it exists. Also
@@ -786,7 +806,7 @@ public abstract class AbstractBrokerFactory implements 
BrokerFactory {
     public Collection<Broker> getOpenBrokers() {
         return Collections.unmodifiableCollection(_brokers);
     }
-
+    
     /**
      * Release <code>broker</code> from any internal data structures. This
      * is invoked by <code>broker</code> after the broker is fully closed.
diff --git 
a/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerFactory.java 
b/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerFactory.java
index cd517d583..391141396 100644
--- a/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerFactory.java
+++ b/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerFactory.java
@@ -24,6 +24,7 @@ import java.util.Set;
 
 import org.apache.openjpa.conf.OpenJPAConfiguration;
 import org.apache.openjpa.lib.util.Closeable;
+import org.apache.openjpa.util.OpenJPAException;
 
 /**
  * Factory for {@link Broker} instances.
@@ -161,4 +162,13 @@ public interface BrokerFactory
      * This method is invoked AFTER a BrokerFactory has been instantiated.
      */
     void postCreationCallback();
+    
+    void createPersistenceStructure(boolean createSchemas);
+    
+    void dropPersistenceStrucuture(boolean dropSchemas);
+
+       void validatePersistenceStruture() throws OpenJPAException;
+
+       void truncateData();
+    
 }
diff --git 
a/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DelegatingBrokerFactory.java
 
b/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DelegatingBrokerFactory.java
index c15956d54..42c3b621d 100644
--- 
a/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DelegatingBrokerFactory.java
+++ 
b/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DelegatingBrokerFactory.java
@@ -22,6 +22,7 @@ import java.util.Map;
 import java.util.Set;
 
 import org.apache.openjpa.conf.OpenJPAConfiguration;
+import org.apache.openjpa.util.OpenJPAException;
 import org.apache.openjpa.util.RuntimeExceptionTranslator;
 
 ///////////////////////////////////////////////////////////////
@@ -259,4 +260,41 @@ public class DelegatingBrokerFactory
             throw translate(re);
         }
     }
+    
+    @Override
+    public void createPersistenceStructure(boolean createSchemas) {
+               try {
+                       _factory.createPersistenceStructure(createSchemas);
+               } catch (RuntimeException re) {
+                       throw translate(re);
+               }
+    }
+
+       @Override
+       public void dropPersistenceStrucuture(boolean dropSchemas) {
+               try {
+                       _factory.dropPersistenceStrucuture(dropSchemas);
+               } catch (RuntimeException re) {
+                       throw translate(re);
+               }
+       }
+       
+       @Override
+       public void validatePersistenceStruture() throws OpenJPAException {
+               try {
+                       _factory.validatePersistenceStruture();
+               } catch (RuntimeException re) {
+                       throw translate(re);
+               }
+       }
+       
+       @Override
+       public void truncateData() {
+               try {
+                       _factory.truncateData();
+               } catch (RuntimeException re) {
+                       throw translate(re);
+               }
+       }
+       
 }
diff --git 
a/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/XMLVersionParser.java 
b/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/XMLVersionParser.java
index 6fbfd8588..05fd0b747 100644
--- 
a/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/XMLVersionParser.java
+++ 
b/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/XMLVersionParser.java
@@ -35,6 +35,7 @@ public class XMLVersionParser extends XMLMetaDataParser {
     public static final String VERSION_2_2 = "2.2";
     public static final String VERSION_3_0 = "3.0";
     public static final String VERSION_3_1 = "3.1";
+    public static final String VERSION_3_2 = "3.2";
 
     static private final String VERSION_ATTR = "version";
     static private final String XSI_NS =
diff --git 
a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/conf/TestGetProperty.java
 
b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/conf/TestGetProperty.java
index 18ca885fe..bbb022a7d 100644
--- 
a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/conf/TestGetProperty.java
+++ 
b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/conf/TestGetProperty.java
@@ -60,6 +60,10 @@ public class TestGetProperty extends TestCase {
             fail(e.getMessage());
         }
     }
+    
+    public void testGetPersistenceUnitName() {
+       assertEquals("test", emf.getName());
+    }
 
     class Test extends Thread {
         EntityManager em;
diff --git 
a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/TestJDBCSchemaManager.java
 
b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/TestJDBCSchemaManager.java
new file mode 100644
index 000000000..5d3fd00f2
--- /dev/null
+++ 
b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/TestJDBCSchemaManager.java
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.openjpa.jdbc.meta;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.StringWriter;
+import java.sql.SQLException;
+import java.util.UUID;
+
+import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
+import org.apache.openjpa.jdbc.schema.SchemaTool;
+import org.apache.openjpa.persistence.OpenJPAEntityManager;
+import org.apache.openjpa.persistence.OpenJPAEntityManagerFactory;
+import org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI;
+import org.apache.openjpa.persistence.common.apps.CompUser;
+import org.apache.openjpa.persistence.common.utils.AbstractTestCase;
+import org.apache.openjpa.persistence.jdbc.common.apps.BuildSchemaPC;
+import org.apache.openjpa.persistence.test.AbstractPersistenceTestCase;
+import org.junit.Test;
+
+import jakarta.persistence.EntityManager;
+import jakarta.persistence.EntityManagerFactory;
+
+/**
+ * Test that a {@link MappingTool#ACTION_REFRESH} uses the right
+ * types for new columns and takes any mapping in DBDictionary into account.
+ */
+public class TestJDBCSchemaManager extends AbstractPersistenceTestCase {
+       
+    /**
+     * First we create a schema mapping with boolean representation as CHAR(1).
+     * Then we create an entry.
+     * After that we create a diff from the entity to the current DB.
+     * This should result in an empty diff.
+     */
+    @Test
+    public void testSchemaReset() throws Exception {
+       
+        EntityManagerFactory emf = createEMF(UUIDEntity.class, DROP_TABLES);
+        EntityManager em = emf.createEntityManager();
+        
+        assertNotNull(em);
+
+        em.getTransaction().begin();
+        UUIDEntity ue1 = new UUIDEntity();
+        ue1.setValue("Something");
+        em.persist(ue1);
+
+        em.getTransaction().commit();
+        UUID id = ue1.getId();
+        closeEM(em);
+
+        EntityManager em2 = emf.createEntityManager();
+        assertNotNull(em2);
+
+        UUIDEntity ue2 = em2.find(UUIDEntity.class, id);
+        assertNotNull(ue2);
+        assertNotEquals(ue1, ue2);
+        
+        closeEM(em2);
+        
+        closeEMF(emf);
+    }
+
+    @Test
+    public void testBuildSchema() throws IOException, SQLException {
+        EntityManagerFactory emf = createEMF(UUIDEntity.class, 
EntityBoolChar.class, DROP_TABLES);
+        emf.createEntityManager();
+
+        emf.getSchemaManager().create(false);
+        emf.getSchemaManager().drop(false);
+
+    }
+    
+    @Test
+    public void testTruncate() {
+        EntityManagerFactory emf = createEMF(UUIDEntity.class, 
EntityBoolChar.class, DROP_TABLES);
+        EntityManager em = emf.createEntityManager();
+
+        em.getTransaction().begin();
+        UUIDEntity ue1 = new UUIDEntity();
+        ue1.setValue("Something");
+        em.persist(ue1);
+
+        em.getTransaction().commit();
+        UUIDEntity ue2 = em.find(UUIDEntity.class, ue1.getId());
+        assertNotNull(ue2);
+        
+        closeEM(em);
+        
+        emf.getSchemaManager().truncate();
+        
+        em = emf.createEntityManager();
+        assertNull(em.find(UUIDEntity.class, ue1.getId()));
+        closeEM(em);
+    }
+
+}
diff --git 
a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/UUIDEntity.java
 
b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/UUIDEntity.java
new file mode 100644
index 000000000..374b256ae
--- /dev/null
+++ 
b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/UUIDEntity.java
@@ -0,0 +1,41 @@
+package org.apache.openjpa.jdbc.meta;
+
+import java.util.UUID;
+
+import jakarta.persistence.Column;
+import jakarta.persistence.Entity;
+import jakarta.persistence.GeneratedValue;
+import jakarta.persistence.GenerationType;
+import jakarta.persistence.Id;
+
+@Entity
+public class UUIDEntity {
+       
+       @Id
+       @GeneratedValue(strategy = GenerationType.UUID)
+       @Column(name = "id_")
+       private UUID id;
+       
+       @Column(name = "value_")
+       private String value;
+       
+       public UUIDEntity() {
+       }
+
+       public UUID getId() {
+               return id;
+       }
+
+       public void setId(UUID id) {
+               this.id = id;
+       }
+
+       public String getValue() {
+               return value;
+       }
+
+       public void setValue(String value) {
+               this.value = value;
+       }
+       
+}
diff --git 
a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerFactoryImpl.java
 
b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerFactoryImpl.java
index 45a4f4a9a..3d7d951b8 100644
--- 
a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerFactoryImpl.java
+++ 
b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerFactoryImpl.java
@@ -436,7 +436,7 @@ public class EntityManagerFactoryImpl
     
     @Override
     public String getName() {
-       throw new UnsupportedOperationException("Not yet implemented (JPA 
3.2)");
+       return (String) _factory.getProperties().get("openjpa.Id");
     }
 
     @Override
@@ -501,7 +501,10 @@ public class EntityManagerFactoryImpl
     
     @Override
     public SchemaManager getSchemaManager() {
-       throw new UnsupportedOperationException("Not yet implemented (JPA 
3.2)");
+       if (!this.isOpen()) {
+               throw new IllegalStateException("EntityManagerFactory is 
closed.");
+       }
+       return new SchemaManagerImpl(_factory);
     }
     
     @Override
diff --git 
a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProductDerivation.java
 
b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProductDerivation.java
index f00a47ad0..a5fa09946 100644
--- 
a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProductDerivation.java
+++ 
b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProductDerivation.java
@@ -766,6 +766,7 @@ public class PersistenceProductDerivation
         private static final String PERSISTENCE_XSD_2_1 = 
"persistence_2_1.xsd";
         private static final String PERSISTENCE_XSD_2_2 = 
"persistence_2_2.xsd";
         private static final String PERSISTENCE_XSD_3_0 = 
"persistence_3_0.xsd";
+        private static final String PERSISTENCE_XSD_3_2 = 
"persistence_3_2.xsd";
 
         private static final Localizer _loc = Localizer.forPackage
             (ConfigurationParser.class);
@@ -843,6 +844,14 @@ public class PersistenceProductDerivation
                     || (_schemaLocation != null && 
_schemaLocation.indexOf(PERSISTENCE_XSD_3_0) != -1)) {
                 persistencexsd = "persistence_3_0.xsd.rsrc";
             }
+            else if (XMLVersionParser.VERSION_3_1.equals(_persistenceVersion)
+                    || (_schemaLocation != null && 
_schemaLocation.indexOf(PERSISTENCE_XSD_3_0) != -1)) {
+                persistencexsd = "persistence_3_0.xsd.rsrc";
+            }
+            else if (XMLVersionParser.VERSION_3_2.equals(_persistenceVersion)
+                    || (_schemaLocation != null && 
_schemaLocation.indexOf(PERSISTENCE_XSD_3_2) != -1)) {
+                persistencexsd = "persistence_3_2.xsd.rsrc";
+            }
 
             return getClass().getResourceAsStream(persistencexsd);
         }
diff --git 
a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProviderImpl.java
 
b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProviderImpl.java
index 09e30477d..6102cad36 100644
--- 
a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProviderImpl.java
+++ 
b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProviderImpl.java
@@ -138,23 +138,22 @@ public class PersistenceProviderImpl
         }
     }
 
-    private BrokerFactory getBrokerFactory(ConfigurationProvider cp,
-        Object poolValue, ClassLoader loader) {
+    private BrokerFactory getBrokerFactory(ConfigurationProvider cp, Object 
poolValue, ClassLoader loader) {
         // handle "true" and "false"
-        if (poolValue instanceof String
-            && ("true".equalsIgnoreCase((String) poolValue)
-                || "false".equalsIgnoreCase((String) poolValue)))
-            poolValue = Boolean.valueOf((String) poolValue);
+        if (poolValue instanceof String pv && ("true".equalsIgnoreCase(pv) || 
"false".equalsIgnoreCase(pv))) {
+            poolValue = Boolean.valueOf(pv);
+        }
 
         if (poolValue != null && !(poolValue instanceof Boolean)) {
             // we only support boolean settings for this option currently.
             throw new IllegalArgumentException(poolValue.toString());
         }
-
-        if (poolValue == null || !(Boolean) poolValue)
+        
+        if (poolValue == null || !((Boolean) poolValue)) {
             return Bootstrap.newBrokerFactory(cp, loader);
-        else
+        } else {
             return Bootstrap.getBrokerFactory(cp, loader);
+        }
     }
 
     @Override
diff --git 
a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/SchemaManagerImpl.java
 
b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/SchemaManagerImpl.java
new file mode 100644
index 000000000..a60ef4664
--- /dev/null
+++ 
b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/SchemaManagerImpl.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openjpa.persistence;
+
+import org.apache.openjpa.kernel.BrokerFactory;
+import org.apache.openjpa.util.OpenJPAException;
+
+import jakarta.persistence.SchemaManager;
+import jakarta.persistence.SchemaValidationException;
+
+/**
+ * Implements a no-op SchemaManager object that will throw 
+ * UnsupportedOperationException if not concretelly implemented
+ * by the given persistence layer.
+ * 
+ * @author Paulo Cristovão Filho
+ */
+public class SchemaManagerImpl implements SchemaManager {
+       
+       private BrokerFactory _factory;
+       
+       public SchemaManagerImpl(BrokerFactory factory) {
+               _factory = factory;
+       }
+
+       @Override
+       public void create(boolean createSchemas) {
+               _factory.createPersistenceStructure(createSchemas);
+       }
+
+       @Override
+       public void drop(boolean dropSchemas) {
+               _factory.dropPersistenceStrucuture(dropSchemas);
+       }
+
+       @Override
+       public void validate() throws SchemaValidationException {
+               try {
+                       _factory.validatePersistenceStruture();
+               } catch (OpenJPAException ex) {
+                       throw new SchemaValidationException("Schema could not 
be validated", ex);
+               }
+       }
+
+       @Override
+       public void truncate() {
+               _factory.truncateData();;
+       }
+
+}
diff --git 
a/openjpa-persistence/src/main/resources/org/apache/openjpa/persistence/persistence_3_2.xsd.rsrc
 
b/openjpa-persistence/src/main/resources/org/apache/openjpa/persistence/persistence_3_2.xsd.rsrc
new file mode 100644
index 000000000..da11bd10c
--- /dev/null
+++ 
b/openjpa-persistence/src/main/resources/org/apache/openjpa/persistence/persistence_3_2.xsd.rsrc
@@ -0,0 +1,383 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    Copyright (c) 2008, 2020 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0 which is available at
+    http://www.eclipse.org/legal/epl-2.0,
+    or the Eclipse Distribution License v. 1.0 which is available at
+    http://www.eclipse.org/org/documents/edl-v10.php.
+
+    SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
+
+-->
+<!-- persistence.xml schema -->
+<xsd:schema targetNamespace="https://jakarta.ee/xml/ns/persistence";
+  xmlns:xsd="http://www.w3.org/2001/XMLSchema";
+  xmlns:persistence="https://jakarta.ee/xml/ns/persistence";
+  elementFormDefault="qualified"
+  attributeFormDefault="unqualified"
+  version="3.2">
+
+   <xsd:annotation>
+     <xsd:documentation><![CDATA[
+
+     This is the XML Schema for the persistence configuration file.
+     The file must be named "META-INF/persistence.xml" in the
+     persistence archive.
+
+     Persistence configuration files must indicate
+     the persistence schema by using the persistence namespace:
+
+     https://jakarta.ee/xml/ns/persistence
+
+     and indicate the version of the schema by
+     using the version element as shown below:
+
+      <persistence xmlns="https://jakarta.ee/xml/ns/persistence";
+        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+        xsi:schemaLocation="https://jakarta.ee/xml/ns/persistence
+          https://jakarta.ee/xml/ns/persistence/persistence_3_2.xsd";
+        version="3.2">
+          ...
+      </persistence>
+
+    ]]></xsd:documentation>
+  </xsd:annotation>
+
+  <xsd:simpleType name="versionType">
+    <xsd:restriction base="xsd:token">
+      <xsd:pattern value="[0-9]+(\.[0-9]+)*"/>
+    </xsd:restriction>
+  </xsd:simpleType>
+
+  <!-- **************************************************** -->
+
+  <xsd:element name="persistence">
+    <xsd:complexType>
+      <xsd:sequence>
+
+        <!-- **************************************************** -->
+
+        <xsd:element name="persistence-unit"
+                     minOccurs="1" maxOccurs="unbounded">
+          <xsd:complexType>
+            <xsd:annotation>
+              <xsd:documentation>
+
+                Configuration of a persistence unit.
+
+              </xsd:documentation>
+            </xsd:annotation>
+            <xsd:sequence>
+
+            <!-- **************************************************** -->
+
+              <xsd:element name="description" type="xsd:string"
+                           minOccurs="0">
+                <xsd:annotation>
+                  <xsd:documentation>
+
+                    Description of this persistence unit.
+
+                  </xsd:documentation>
+                </xsd:annotation>
+              </xsd:element>
+
+              <!-- **************************************************** -->
+
+              <xsd:element name="provider" type="xsd:string"
+                           minOccurs="0">
+                <xsd:annotation>
+                  <xsd:documentation>
+
+                    Provider class that supplies EntityManagers for this
+                    persistence unit.
+
+                  </xsd:documentation>
+                </xsd:annotation>
+              </xsd:element>
+
+              <!-- **************************************************** -->
+
+              <xsd:element name="qualifier" type="xsd:string"
+                           minOccurs="0" maxOccurs="unbounded">
+                <xsd:annotation>
+                  <xsd:documentation>
+
+                    Qualifier annotation class used for dependency injection.
+
+                  </xsd:documentation>
+                </xsd:annotation>
+              </xsd:element>
+
+              <!-- **************************************************** -->
+
+              <xsd:element name="scope" type="xsd:string"
+                           minOccurs="0">
+                <xsd:annotation>
+                  <xsd:documentation>
+
+                    Scope annotation class used for dependency injection.
+
+                  </xsd:documentation>
+                </xsd:annotation>
+              </xsd:element>
+
+              <!-- **************************************************** -->
+
+              <xsd:element name="jta-data-source" type="xsd:string"
+                           minOccurs="0">
+                <xsd:annotation>
+                  <xsd:documentation>
+
+                    The container-specific name of the JTA datasource to use.
+
+                  </xsd:documentation>
+                </xsd:annotation>
+              </xsd:element>
+
+              <!-- **************************************************** -->
+
+              <xsd:element name="non-jta-data-source" type="xsd:string"
+                           minOccurs="0">
+                <xsd:annotation>
+                  <xsd:documentation>
+
+                    The container-specific name of a non-JTA datasource to use.
+
+                  </xsd:documentation>
+                </xsd:annotation>
+              </xsd:element>
+
+              <!-- **************************************************** -->
+
+              <xsd:element name="mapping-file" type="xsd:string"
+                           minOccurs="0" maxOccurs="unbounded">
+                <xsd:annotation>
+                  <xsd:documentation>
+
+                    File containing mapping information. Loaded as a resource
+                    by the persistence provider.
+
+                  </xsd:documentation>
+                </xsd:annotation>
+              </xsd:element>
+
+              <!-- **************************************************** -->
+
+              <xsd:element name="jar-file" type="xsd:string"
+                           minOccurs="0" maxOccurs="unbounded">
+                <xsd:annotation>
+                  <xsd:documentation>
+
+                    Jar file that is to be scanned for managed classes.
+
+                  </xsd:documentation>
+                </xsd:annotation>
+              </xsd:element>
+
+              <!-- **************************************************** -->
+
+              <xsd:element name="class" type="xsd:string"
+                           minOccurs="0" maxOccurs="unbounded">
+                <xsd:annotation>
+                  <xsd:documentation>
+
+                    Managed class to be included in the persistence unit and
+                    to scan for annotations.  It should be annotated
+                    with either @Entity, @Embeddable or @MappedSuperclass.
+
+                  </xsd:documentation>
+                </xsd:annotation>
+              </xsd:element>
+
+              <!-- **************************************************** -->
+
+              <xsd:element name="exclude-unlisted-classes" type="xsd:boolean"
+                           default="true" minOccurs="0">
+                <xsd:annotation>
+                  <xsd:documentation>
+
+                    When set to true then only listed classes and jars will
+                    be scanned for persistent classes, otherwise the
+                    enclosing jar or directory will also be scanned.
+                    Not applicable to Java SE persistence units.
+
+                  </xsd:documentation>
+                </xsd:annotation>
+              </xsd:element>
+
+              <!-- **************************************************** -->
+
+              <xsd:element name="shared-cache-mode"
+                           type="persistence:persistence-unit-caching-type"
+                           minOccurs="0">
+                <xsd:annotation>
+                  <xsd:documentation>
+
+                    Defines whether caching is enabled for the
+                    persistence unit if caching is supported by the
+                    persistence provider. When set to ALL, all entities
+                    will be cached. When set to NONE, no entities will
+                    be cached. When set to ENABLE_SELECTIVE, only entities
+                    specified as cacheable will be cached. When set to
+                    DISABLE_SELECTIVE, entities specified as not cacheable
+                    will not be cached. When not specified or when set to
+                    UNSPECIFIED, provider defaults may apply.
+
+                  </xsd:documentation>
+                </xsd:annotation>
+              </xsd:element>
+
+              <!-- **************************************************** -->
+
+              <xsd:element name="validation-mode"
+                           
type="persistence:persistence-unit-validation-mode-type"
+                           minOccurs="0">
+                <xsd:annotation>
+                  <xsd:documentation>
+
+                    The validation mode to be used for the persistence unit.
+
+                  </xsd:documentation>
+                </xsd:annotation>
+              </xsd:element>
+
+
+              <!-- **************************************************** -->
+
+              <xsd:element name="properties" minOccurs="0">
+                <xsd:annotation>
+                  <xsd:documentation>
+
+                    A list of standard and vendor-specific properties
+                    and hints.
+
+                  </xsd:documentation>
+                </xsd:annotation>
+                <xsd:complexType>
+                  <xsd:sequence>
+                    <xsd:element name="property"
+                                 minOccurs="0" maxOccurs="unbounded">
+                      <xsd:annotation>
+                        <xsd:documentation>
+                          A name-value pair.
+                        </xsd:documentation>
+                      </xsd:annotation>
+                      <xsd:complexType>
+                        <xsd:attribute name="name" type="xsd:string"
+                                       use="required"/>
+                        <xsd:attribute name="value" type="xsd:string"
+                                       use="required"/>
+                      </xsd:complexType>
+                    </xsd:element>
+                  </xsd:sequence>
+                </xsd:complexType>
+              </xsd:element>
+
+              <xsd:any namespace="##other" processContents="lax"
+                       minOccurs="0" maxOccurs="unbounded">
+                <xsd:annotation>
+                  <xsd:documentation>
+                    An extension point for integration related configuration, 
e.g. cdi:
+                    <!--
+                    <persistence-unit name="my-unit" 
xmlns:cdi="https://jakarta.ee/xml/ns/persistence-cdi";>
+                      ...
+                      <cdi:scope>com.example.jpa.ACustomScope</cdi:scope>
+                      
<cdi:qualifier>com.example.jpa.CustomQualifier</cdi:qualifier>
+                    </persistence-unit>
+                    -->
+                  </xsd:documentation>
+                </xsd:annotation>
+              </xsd:any>
+            </xsd:sequence>
+
+            <!-- **************************************************** -->
+
+            <xsd:attribute name="name" type="xsd:string" use="required">
+              <xsd:annotation>
+                <xsd:documentation>
+
+                  Name used in code to reference this persistence unit.
+
+                </xsd:documentation>
+              </xsd:annotation>
+            </xsd:attribute>
+
+            <!-- **************************************************** -->
+
+            <xsd:attribute name="transaction-type"
+                           
type="persistence:persistence-unit-transaction-type">
+              <xsd:annotation>
+                <xsd:documentation>
+
+                  Type of transactions used by EntityManagers from this
+                  persistence unit.
+
+                </xsd:documentation>
+              </xsd:annotation>
+            </xsd:attribute>
+
+          </xsd:complexType>
+        </xsd:element>
+      </xsd:sequence>
+      <xsd:attribute name="version" type="persistence:versionType"
+                     fixed="3.2" use="required"/>
+    </xsd:complexType>
+  </xsd:element>
+
+  <!-- **************************************************** -->
+
+  <xsd:simpleType name="persistence-unit-transaction-type">
+    <xsd:annotation>
+      <xsd:documentation>
+
+        public enum PersistenceUnitTransactionType {JTA, RESOURCE_LOCAL};
+
+      </xsd:documentation>
+    </xsd:annotation>
+    <xsd:restriction base="xsd:token">
+      <xsd:enumeration value="JTA"/>
+      <xsd:enumeration value="RESOURCE_LOCAL"/>
+    </xsd:restriction>
+  </xsd:simpleType>
+
+<!-- **************************************************** -->
+
+  <xsd:simpleType name="persistence-unit-caching-type">
+    <xsd:annotation>
+      <xsd:documentation>
+
+        public enum SharedCacheMode { ALL, NONE, ENABLE_SELECTIVE, 
DISABLE_SELECTIVE, UNSPECIFIED};
+
+      </xsd:documentation>
+    </xsd:annotation>
+    <xsd:restriction base="xsd:token">
+      <xsd:enumeration value="ALL"/>
+      <xsd:enumeration value="NONE"/>
+      <xsd:enumeration value="ENABLE_SELECTIVE"/>
+      <xsd:enumeration value="DISABLE_SELECTIVE"/>
+      <xsd:enumeration value="UNSPECIFIED"/>
+    </xsd:restriction>
+  </xsd:simpleType>
+
+<!-- **************************************************** -->
+
+  <xsd:simpleType name="persistence-unit-validation-mode-type">
+    <xsd:annotation>
+      <xsd:documentation>
+
+        public enum ValidationMode { AUTO, CALLBACK, NONE};
+
+      </xsd:documentation>
+    </xsd:annotation>
+    <xsd:restriction base="xsd:token">
+      <xsd:enumeration value="AUTO"/>
+      <xsd:enumeration value="CALLBACK"/>
+      <xsd:enumeration value="NONE"/>
+    </xsd:restriction>
+  </xsd:simpleType>
+
+</xsd:schema>
+


Reply via email to