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 3e9b57c7ecdc54d97a8ab274d83889e9810ccea8
Author: Paulo Cristovão de Araújo Silva Filho <[email protected]>
AuthorDate: Fri Jul 11 16:34:40 2025 -0300

    [OPENJPA-2940][WIP] Fixing H2 deleteTableContents and adding license.
---
 .../java/org/apache/openjpa/jdbc/sql/H2Dictionary.java | 18 ++++++++++++++++++
 .../java/org/apache/openjpa/jdbc/meta/UUIDEntity.java  | 18 ++++++++++++++++++
 2 files changed, 36 insertions(+)

diff --git 
a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/H2Dictionary.java 
b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/H2Dictionary.java
index a541b12b6..f66acf1e3 100644
--- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/H2Dictionary.java
+++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/H2Dictionary.java
@@ -153,6 +153,11 @@ public class H2Dictionary extends DBDictionary {
             "WITH",
             "YEAR",
             "_ROWID_");
+    
+    private final static List<String> V2_META_TABLES_NAMES = Arrays
+               .asList("INFORMATION_SCHEMA.INDEXES", 
"INFORMATION_SCHEMA.INDEX_COLUMNS", 
"INFORMATION_SCHEMA.INFORMATION_SCHEMA_CATALOG_NAME",
+                               "INFORMATION_SCHEMA.ROLES", 
"INFORMATION_SCHEMA.SESSIONS", "INFORMATION_SCHEMA.SESSION_STATE",
+                               "INFORMATION_SCHEMA.SETTINGS", 
"INFORMATION_SCHEMA.USERS");
 
     public H2Dictionary() {
         platform = "H2";
@@ -482,4 +487,17 @@ public class H2Dictionary extends DBDictionary {
         }
         return super.isFatalException(subtype, ex);
     }
+    
+    @Override
+    public String[] getDeleteTableContentsSQL(Table[] tables, Connection conn) 
{
+       if (versionLaterThan(1)) {
+               List<Table> tbs = Arrays.asList(tables).stream()
+                               .filter(tb -> 
!V2_META_TABLES_NAMES.contains(tb.getFullIdentifier().toString()))
+                               .toList();
+               return super.getDeleteTableContentsSQL(tbs.toArray(new Table[] 
{}), conn);
+       } else {
+               return super.getDeleteTableContentsSQL(tables, conn);
+       }
+    }
+    
 }
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
index 374b256ae..d65ab7638 100644
--- 
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
@@ -1,3 +1,21 @@
+/*
+ * 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.util.UUID;

Reply via email to