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 f129a9192d70a4c5d6e27f31af40ee6e3ea1a017
Author: Paulo Cristovão de Araújo Silva Filho <pcris...@gmail.com>
AuthorDate: Tue Jul 8 09:10:27 2025 -0300

    [OPENJPA-2940][WIP] Updated mariadb and mysql behavior with new drivers
    
    * Project passes tests on derby, h2-2, postgres:latest, mysql:lts,
    mariadb:lts
---
 openjpa-examples/openbooks/pom.xml                           |  4 ++--
 .../java/org/apache/openjpa/jdbc/sql/MariaDBDictionary.java  |  5 -----
 .../java/org/apache/openjpa/jdbc/sql/MySQLDictionary.java    |  6 ++++--
 .../persistence/batch/exception/TestBatchLimitException.java |  9 +++++++--
 .../apache/openjpa/persistence/query/TestJDBCEscapeDate.java |  3 ++-
 openjpa-slice/pom.xml                                        |  4 ++--
 pom.xml                                                      | 12 ++++++------
 7 files changed, 23 insertions(+), 20 deletions(-)

diff --git a/openjpa-examples/openbooks/pom.xml 
b/openjpa-examples/openbooks/pom.xml
index ab3b410d1..f3df61ba4 100644
--- a/openjpa-examples/openbooks/pom.xml
+++ b/openjpa-examples/openbooks/pom.xml
@@ -70,8 +70,8 @@
             <scope>provided</scope>
         </dependency>
         <dependency>
-            <groupId>mysql</groupId>
-            <artifactId>mysql-connector-java</artifactId>
+            <groupId>com.mysql</groupId>
+            <artifactId>mysql-connector-j</artifactId>
             <scope>provided</scope>
         </dependency>
         <dependency>
diff --git 
a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MariaDBDictionary.java 
b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MariaDBDictionary.java
index ada65b307..4864012b3 100644
--- 
a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MariaDBDictionary.java
+++ 
b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MariaDBDictionary.java
@@ -428,11 +428,6 @@ public class MariaDBDictionary extends DBDictionary {
         buf.append("')");
     }
 
-    @Override
-    public int getBatchFetchSize(int batchFetchSize) {
-        return Integer.MIN_VALUE;
-    }
-
     /**
      * Check to see if we have set the {@link #SELECT_HINT} in the
      * fetch configuration, and if so, append the MySQL hint after the
diff --git 
a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MySQLDictionary.java 
b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MySQLDictionary.java
index 988f05857..fba08a48c 100644
--- 
a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MySQLDictionary.java
+++ 
b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MySQLDictionary.java
@@ -155,7 +155,7 @@ public class MySQLDictionary
             "SQLEXCEPTION", "SQLSTATE", "SQLWARNING", "SSL", "STARTING", 
"STRAIGHT_JOIN", "TABLE", "TERMINATED", "THEN", "TINYBLOB",
             "TINYINT", "TINYTEXT", "TO", "TRAILING", "TRIGGER", "TRUE", 
"UNDO", "UNION", "UNIQUE", "UNLOCK", "UNSIGNED", "UPDATE",
             "USAGE", "USE", "USING", "UTC_DATE", "UTC_TIME", "UTC_TIMESTAMP", 
"VALUES", "VARBINARY", "VARCHAR", "VARCHARACTER",
-            "VARYING", "WHEN", "WHERE", "WHILE", "WITH", "WRITE", "XOR", 
"YEAR_MONTH", "ZEROFILL",
+            "VARYING", "WHEN", "WHERE", "WHILE", "WITH", "WRITE", "XOR", 
"YEAR_MONTH", "ZEROFILL", "NTILE",
             // end generated.
             // the following keywords used to be defined as reserved words in 
the past, but now seem to work
             // we still add them for compat reasons
@@ -466,7 +466,9 @@ public class MySQLDictionary
         if (state == ExceptionInfo.GENERAL && ex.getErrorCode() == 0 && 
ex.getSQLState() == null) {
             // look at the nested MySQL exception for more details
             SQLException sqle = ex.getNextException();
-            if (sqle != null && 
sqle.toString().startsWith("com.mysql.jdbc.exceptions.MySQLTimeoutException")) {
+            if (sqle != null 
+                       && 
(sqle.toString().startsWith("com.mysql.jdbc.exceptions.MySQLTimeoutException") 
|| 
+                                       
sqle.toString().startsWith("com.mysql.cj.jdbc.exceptions.MySQLTimeoutException")))
 {
                 if (conf != null && conf.getLockTimeout() != -1) {
                     state = StoreException.LOCK;
                 } else {
diff --git 
a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/batch/exception/TestBatchLimitException.java
 
b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/batch/exception/TestBatchLimitException.java
index 58e19adf5..ffe9ec420 100644
--- 
a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/batch/exception/TestBatchLimitException.java
+++ 
b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/batch/exception/TestBatchLimitException.java
@@ -23,6 +23,8 @@ import jakarta.persistence.EntityManagerFactory;
 
 import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
 import org.apache.openjpa.jdbc.sql.DBDictionary;
+import org.apache.openjpa.jdbc.sql.MariaDBDictionary;
+import org.apache.openjpa.jdbc.sql.MySQLDictionary;
 import org.apache.openjpa.jdbc.sql.OracleDictionary;
 import org.apache.openjpa.jdbc.sql.PostgresDictionary;
 import org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI;
@@ -42,6 +44,7 @@ public class TestBatchLimitException extends 
AbstractPersistenceTestCase {
 
     static boolean isOracle = false;
     static boolean isPostgres = false;
+    static boolean isMariaDB = false;
 
     final String expectedFailureMsg =
         "INSERT INTO Ent1 (pk, name) VALUES (?, ?) [params=(int) 200, (String) 
twohundred]";
@@ -63,6 +66,7 @@ public class TestBatchLimitException extends 
AbstractPersistenceTestCase {
         DBDictionary dict = conf.getDBDictionaryInstance();
         isOracle = dict instanceof OracleDictionary;
         isPostgres = dict instanceof PostgresDictionary;
+        isMariaDB = dict instanceof MariaDBDictionary;
         return emf;
     }
 
@@ -103,6 +107,7 @@ public class TestBatchLimitException extends 
AbstractPersistenceTestCase {
 
         try {
             em2.getTransaction().commit();
+            fail("Should have thrown exception because of the duplicate key");
         } catch (Throwable excp) {
             verifyExDetails(excp);
         }
@@ -353,7 +358,7 @@ public class TestBatchLimitException extends 
AbstractPersistenceTestCase {
             Ent1 failedObject = (Ent1) e.getFailedObject();
 
             assertNotNull("Failed object was null.", failedObject);
-            if (!isOracle && !isPostgres) {
+            if (!isOracle && !isPostgres && !isMariaDB) {
                 assertEquals(expectedFailedObject, failedObject);
             } else if (isOracle) {
                 // since Oracle 18 we see a different behaviour, so test both 
ways
@@ -370,7 +375,7 @@ public class TestBatchLimitException extends 
AbstractPersistenceTestCase {
 
     public void verifyExMsg(String msg) {
         assertNotNull("Exception message was null.", msg);
-        if (!isOracle && !isPostgres) {
+        if (!isOracle && !isPostgres && !isMariaDB) {
             assertTrue("Did not see expected text in message. Expected <" + 
expectedFailureMsg + "> but was " +
                 msg, msg.contains(expectedFailureMsg));
         } else if (isOracle) {
diff --git 
a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestJDBCEscapeDate.java
 
b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestJDBCEscapeDate.java
index dce4be63a..658201a39 100644
--- 
a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestJDBCEscapeDate.java
+++ 
b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestJDBCEscapeDate.java
@@ -29,6 +29,7 @@ import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
 import org.apache.openjpa.jdbc.sql.DBDictionary;
 import org.apache.openjpa.jdbc.sql.H2Dictionary;
 import org.apache.openjpa.jdbc.sql.HSQLDictionary;
+import org.apache.openjpa.jdbc.sql.MySQLDictionary;
 import org.apache.openjpa.jdbc.sql.PostgresDictionary;
 import org.apache.openjpa.jdbc.sql.SQLServerDictionary;
 import org.apache.openjpa.jdbc.sql.SybaseDictionary;
@@ -98,7 +99,7 @@ public class TestJDBCEscapeDate extends SingleEMFTestCase {
                 "select a from Employee a where a.hireTimestamp >= {ts 
'2009-08-25 00:00:00.123456'}",
                 "select {t '00:00:00'}, a.empId from Employee a",
             };
-        } else if (dict instanceof PostgresDictionary || dict instanceof 
H2Dictionary) {
+        } else if (dict instanceof PostgresDictionary || dict instanceof 
H2Dictionary || dict instanceof MySQLDictionary) {
             jpql = new String[] {
                 "select a from Employee a where a.hireDate >= {d 
'2009-08-25'}",
                 "select a from Employee a where a.hireDate >= {d '2009-8-5'}",
diff --git a/openjpa-slice/pom.xml b/openjpa-slice/pom.xml
index 1c880486e..c40be82eb 100644
--- a/openjpa-slice/pom.xml
+++ b/openjpa-slice/pom.xml
@@ -82,8 +82,8 @@
             </activation>
             <dependencies>
                 <dependency>
-                    <groupId>mysql</groupId>
-                    <artifactId>mysql-connector-java</artifactId>
+                    <groupId>com.mysql</groupId>
+                    <artifactId>mysql-connector-j</artifactId>
                     <version>${mysql.connector.version}</version>
                     <scope>test</scope>
                 </dependency>
diff --git a/pom.xml b/pom.xml
index f82c0808d..b4fec496f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -78,8 +78,8 @@
         <!-- common JDBC driver versions -->
         <derby.version>10.16.1.1</derby.version>
         <hsqldb.version>2.7.4</hsqldb.version>
-        <mysql.connector.version>8.0.33</mysql.connector.version>
-        <mariadb.connector.version>3.5.3</mariadb.connector.version>
+        <mysql.connector.version>9.3.0</mysql.connector.version>
+        <mariadb.connector.version>3.5.4</mariadb.connector.version>
         <postgresql.connector.version>42.7.7</postgresql.connector.version>
         <mssql.connector.version>12.10.0.jre11</mssql.connector.version>
 
@@ -610,8 +610,8 @@
             </activation>
             <dependencies>
                 <dependency>
-                    <groupId>mysql</groupId>
-                    <artifactId>mysql-connector-java</artifactId>
+                    <groupId>com.mysql</groupId>
+                    <artifactId>mysql-connector-j</artifactId>
                     <version>${mysql.connector.version}</version>
                     <scope>test</scope>
                 </dependency>
@@ -1816,8 +1816,8 @@
                 <version>${derby.version}</version>
             </dependency>
             <dependency>
-                <groupId>mysql</groupId>
-                <artifactId>mysql-connector-java</artifactId>
+                <groupId>com.mysql</groupId>
+                <artifactId>mysql-connector-j</artifactId>
                 <version>${mysql.connector.version}</version>
             </dependency>
             <dependency>

Reply via email to