Skip to content

Commit 52bdda7

Browse files
yrodieregbadner
authored andcommitted
HHH-13582 Upgrade MySQL Connector/J to 8.0.17
ConnectorJ 8 is the version used in WildFly integration tests. ConnectorJ 5 is apparently no longer tested. Note this solves most timezone-related issues we've been having. (cherry picked from commit be7cc76)
1 parent 5274f15 commit 52bdda7

File tree

5 files changed

+23
-12
lines changed

5 files changed

+23
-12
lines changed

gradle/libraries.gradle

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,7 @@ ext {
110110
hsqldb: "org.hsqldb:hsqldb:2.3.2",
111111
derby: "org.apache.derby:derby:10.11.1.1",
112112
postgresql: 'org.postgresql:postgresql:42.2.2',
113-
//Upgrade MySQL Driver only when this issue gets fixed: https://bugs.mysql.com/bug.php?id=85941
114-
mysql: 'mysql:mysql-connector-java:5.1.46',
113+
mysql: 'mysql:mysql-connector-java:8.0.17',
115114
mariadb: 'org.mariadb.jdbc:mariadb-java-client:2.2.3',
116115

117116
oracle: 'com.oracle.jdbc:ojdbc8:12.2.0.1',

hibernate-core/src/test/java/org/hibernate/test/annotations/EntityTest.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@
2424
import org.hibernate.boot.MetadataBuilder;
2525
import org.hibernate.boot.model.naming.ImplicitNamingStrategyJpaCompliantImpl;
2626
import org.hibernate.dialect.Dialect;
27-
import org.hibernate.dialect.MySQL57Dialect;
28-
import org.hibernate.dialect.MySQL8Dialect;
29-
import org.hibernate.dialect.MySQLDialect;
27+
import org.hibernate.dialect.MySQL5Dialect;
3028
import org.hibernate.dialect.Oracle10gDialect;
3129
import org.hibernate.query.Query;
3230
import org.hibernate.tool.hbm2ddl.SchemaExport;
@@ -373,7 +371,7 @@ public void testNonGetter() throws Exception {
373371
@SkipForDialect(value = Oracle10gDialect.class, comment = "oracle12c returns time in getDate. For now, skip.")
374372
public void testTemporalType() throws Exception {
375373

376-
final ZoneId zoneId = ( Dialect.getDialect() instanceof MySQL8Dialect ) ? ZoneId.of( "UTC")
374+
final ZoneId zoneId = ( Dialect.getDialect() instanceof MySQL5Dialect ) ? ZoneId.of( "UTC")
377375
: ZoneId.systemDefault();
378376

379377
Flight airFrance = doInHibernate( this::sessionFactory, session -> {

hibernate-core/src/test/java/org/hibernate/test/resource/transaction/jdbc/autocommit/MySQLSkipAutoCommitTest.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,20 @@ protected DataSource dataSource() {
3030
if ( getDialect() instanceof MariaDBDialect ) {
3131
dataSource = ReflectionUtil.newInstance( "org.mariadb.jdbc.MariaDbDataSource" );
3232
}
33-
else if ( getDialect() instanceof MySQL8Dialect ) {
34-
dataSource = ReflectionUtil.newInstance( "com.mysql.cj.jdbc.MysqlDataSource" );
35-
}
3633
else if ( getDialect() instanceof MySQLDialect ) {
37-
dataSource = ReflectionUtil.newInstance( "com.mysql.jdbc.jdbc2.optional.MysqlDataSource" );
34+
try {
35+
// ConnectorJ 8
36+
dataSource = ReflectionUtil.newInstance( "com.mysql.cj.jdbc.MysqlDataSource" );
37+
}
38+
catch (IllegalArgumentException e) {
39+
try {
40+
// ConnectorJ 5
41+
dataSource = ReflectionUtil.newInstance( "com.mysql.jdbc.jdbc2.optional.MysqlDataSource" );
42+
} catch (Exception e2) {
43+
e2.addSuppressed( e );
44+
throw e;
45+
}
46+
}
3847
}
3948
ReflectionUtil.setProperty( dataSource, "url", Environment.getProperties().getProperty( AvailableSettings.URL ) );
4049
ReflectionUtil.setProperty( dataSource, "user", Environment.getProperties().getProperty( AvailableSettings.USER ) );

hibernate-core/src/test/java/org/hibernate/test/temporal/TimePropertyTest.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import java.sql.Time;
1010
import java.text.DateFormat;
1111
import java.text.SimpleDateFormat;
12+
import java.util.Calendar;
1213
import java.util.Date;
1314
import javax.persistence.GeneratedValue;
1415
import javax.persistence.Id;
@@ -36,7 +37,11 @@ public class TimePropertyTest extends BaseCoreFunctionalTestCase {
3637
@Test
3738
public void testTimeAsDate() {
3839
final Entity eOrig = new Entity();
39-
eOrig.tAsDate = new Time( new Date().getTime() );
40+
Calendar calendar = Calendar.getInstance();
41+
// See javadoc for java.sql.Time: 'The date components should be set to the "zero epoch" value of January 1, 1970 and should not be accessed'
42+
// Other dates can potentially lead to errors in JDBC drivers, in particular MySQL ConnectorJ 8.x.
43+
calendar.set( 1970, Calendar.JANUARY, 1 );
44+
eOrig.tAsDate = new Time( calendar.getTimeInMillis() );
4045

4146
Session s = openSession();
4247
s.getTransaction().begin();

hibernate-spatial/databases/mysql56/matrix.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
55
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
66
*/
7-
jdbcDependency "mysql:mysql-connector-java:5.1.15"
7+
jdbcDependency "mysql:mysql-connector-java:8.0.17"

0 commit comments

Comments
 (0)