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 be7cc76556)
This commit is contained in:
Yoann Rodière 2019-08-26 13:53:29 +02:00 committed by gbadner
parent 5274f15ef5
commit 52bdda7d40
5 changed files with 23 additions and 12 deletions

View File

@ -110,8 +110,7 @@ ext {
hsqldb: "org.hsqldb:hsqldb:2.3.2", hsqldb: "org.hsqldb:hsqldb:2.3.2",
derby: "org.apache.derby:derby:10.11.1.1", derby: "org.apache.derby:derby:10.11.1.1",
postgresql: 'org.postgresql:postgresql:42.2.2', postgresql: 'org.postgresql:postgresql:42.2.2',
//Upgrade MySQL Driver only when this issue gets fixed: https://bugs.mysql.com/bug.php?id=85941 mysql: 'mysql:mysql-connector-java:8.0.17',
mysql: 'mysql:mysql-connector-java:5.1.46',
mariadb: 'org.mariadb.jdbc:mariadb-java-client:2.2.3', mariadb: 'org.mariadb.jdbc:mariadb-java-client:2.2.3',
oracle: 'com.oracle.jdbc:ojdbc8:12.2.0.1', oracle: 'com.oracle.jdbc:ojdbc8:12.2.0.1',

View File

@ -24,9 +24,7 @@ import org.hibernate.Transaction;
import org.hibernate.boot.MetadataBuilder; import org.hibernate.boot.MetadataBuilder;
import org.hibernate.boot.model.naming.ImplicitNamingStrategyJpaCompliantImpl; import org.hibernate.boot.model.naming.ImplicitNamingStrategyJpaCompliantImpl;
import org.hibernate.dialect.Dialect; import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.MySQL57Dialect; import org.hibernate.dialect.MySQL5Dialect;
import org.hibernate.dialect.MySQL8Dialect;
import org.hibernate.dialect.MySQLDialect;
import org.hibernate.dialect.Oracle10gDialect; import org.hibernate.dialect.Oracle10gDialect;
import org.hibernate.query.Query; import org.hibernate.query.Query;
import org.hibernate.tool.hbm2ddl.SchemaExport; import org.hibernate.tool.hbm2ddl.SchemaExport;
@ -373,7 +371,7 @@ public class EntityTest extends BaseNonConfigCoreFunctionalTestCase {
@SkipForDialect(value = Oracle10gDialect.class, comment = "oracle12c returns time in getDate. For now, skip.") @SkipForDialect(value = Oracle10gDialect.class, comment = "oracle12c returns time in getDate. For now, skip.")
public void testTemporalType() throws Exception { public void testTemporalType() throws Exception {
final ZoneId zoneId = ( Dialect.getDialect() instanceof MySQL8Dialect ) ? ZoneId.of( "UTC") final ZoneId zoneId = ( Dialect.getDialect() instanceof MySQL5Dialect ) ? ZoneId.of( "UTC")
: ZoneId.systemDefault(); : ZoneId.systemDefault();
Flight airFrance = doInHibernate( this::sessionFactory, session -> { Flight airFrance = doInHibernate( this::sessionFactory, session -> {

View File

@ -30,11 +30,20 @@ public class MySQLSkipAutoCommitTest extends AbstractSkipAutoCommitTest {
if ( getDialect() instanceof MariaDBDialect ) { if ( getDialect() instanceof MariaDBDialect ) {
dataSource = ReflectionUtil.newInstance( "org.mariadb.jdbc.MariaDbDataSource" ); dataSource = ReflectionUtil.newInstance( "org.mariadb.jdbc.MariaDbDataSource" );
} }
else if ( getDialect() instanceof MySQL8Dialect ) {
dataSource = ReflectionUtil.newInstance( "com.mysql.cj.jdbc.MysqlDataSource" );
}
else if ( getDialect() instanceof MySQLDialect ) { else if ( getDialect() instanceof MySQLDialect ) {
dataSource = ReflectionUtil.newInstance( "com.mysql.jdbc.jdbc2.optional.MysqlDataSource" ); try {
// ConnectorJ 8
dataSource = ReflectionUtil.newInstance( "com.mysql.cj.jdbc.MysqlDataSource" );
}
catch (IllegalArgumentException e) {
try {
// ConnectorJ 5
dataSource = ReflectionUtil.newInstance( "com.mysql.jdbc.jdbc2.optional.MysqlDataSource" );
} catch (Exception e2) {
e2.addSuppressed( e );
throw e;
}
}
} }
ReflectionUtil.setProperty( dataSource, "url", Environment.getProperties().getProperty( AvailableSettings.URL ) ); ReflectionUtil.setProperty( dataSource, "url", Environment.getProperties().getProperty( AvailableSettings.URL ) );
ReflectionUtil.setProperty( dataSource, "user", Environment.getProperties().getProperty( AvailableSettings.USER ) ); ReflectionUtil.setProperty( dataSource, "user", Environment.getProperties().getProperty( AvailableSettings.USER ) );

View File

@ -9,6 +9,7 @@ package org.hibernate.test.temporal;
import java.sql.Time; import java.sql.Time;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date; import java.util.Date;
import javax.persistence.GeneratedValue; import javax.persistence.GeneratedValue;
import javax.persistence.Id; import javax.persistence.Id;
@ -36,7 +37,11 @@ public class TimePropertyTest extends BaseCoreFunctionalTestCase {
@Test @Test
public void testTimeAsDate() { public void testTimeAsDate() {
final Entity eOrig = new Entity(); final Entity eOrig = new Entity();
eOrig.tAsDate = new Time( new Date().getTime() ); Calendar calendar = Calendar.getInstance();
// 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'
// Other dates can potentially lead to errors in JDBC drivers, in particular MySQL ConnectorJ 8.x.
calendar.set( 1970, Calendar.JANUARY, 1 );
eOrig.tAsDate = new Time( calendar.getTimeInMillis() );
Session s = openSession(); Session s = openSession();
s.getTransaction().begin(); s.getTransaction().begin();

View File

@ -4,4 +4,4 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. * License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>. * See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/ */
jdbcDependency "mysql:mysql-connector-java:5.1.15" jdbcDependency "mysql:mysql-connector-java:8.0.17"