File tree Expand file tree Collapse file tree 5 files changed +23
-12
lines changed
hibernate-core/src/test/java/org/hibernate/test
resource/transaction/jdbc/autocommit
hibernate-spatial/databases/mysql56 Expand file tree Collapse file tree 5 files changed +23
-12
lines changed Original file line number Diff line number Diff 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' ,
Original file line number Diff line number Diff line change 2424import org .hibernate .boot .MetadataBuilder ;
2525import org .hibernate .boot .model .naming .ImplicitNamingStrategyJpaCompliantImpl ;
2626import 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 ;
3028import org .hibernate .dialect .Oracle10gDialect ;
3129import org .hibernate .query .Query ;
3230import 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 -> {
Original file line number Diff line number Diff 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 ) );
Original file line number Diff line number Diff line change 99import java .sql .Time ;
1010import java .text .DateFormat ;
1111import java .text .SimpleDateFormat ;
12+ import java .util .Calendar ;
1213import java .util .Date ;
1314import javax .persistence .GeneratedValue ;
1415import 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 ();
Original file line number Diff line number Diff line change 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 "
You can’t perform that action at this time.
0 commit comments