#1775 - MySql 8 by default wants JDBC Date set and read with JVM Calendar (timezone)

This commit is contained in:
rob bygrave
2019-07-25 21:25:38 +12:00
parent b04f887bc3
commit 5a39dcb39c
12 changed files with 66 additions and 13 deletions
+2 -2
View File
@@ -7,7 +7,7 @@ public class StartMySql {
public static void main(String[] args) {
MySqlConfig config = new MySqlConfig("5.7");
MySqlConfig config = new MySqlConfig("8.0");
config.setDbName("unit");
config.setUser("unit");
config.setPassword("unit");
@@ -23,6 +23,6 @@ public class StartMySql {
// config.setCharacterSet("utf8mb4");
MySqlContainer container = new MySqlContainer(config);
container.start();
container.startWithDropCreate();
}
}
@@ -19,7 +19,7 @@ import static org.junit.Assert.assertNotNull;
public class TestAggregateFormula extends BaseTestCase {
@IgnorePlatform(Platform.SQLSERVER)
@IgnorePlatform({Platform.SQLSERVER, Platform.MYSQL})
@Test
public void minDistinctOrderByNulls() {
@@ -5,6 +5,7 @@ import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Version;
import java.nio.file.Path;
import java.sql.Date;
import java.time.DayOfWeek;
import java.time.Duration;
import java.time.Instant;
@@ -45,6 +46,8 @@ public class SomeNewTypesBean {
@Column(name = "month_day")
MonthDay monthDay;
java.sql.Date sqlDate;
LocalDate localDate;
LocalDateTime localDateTime;
@@ -123,6 +126,14 @@ public class SomeNewTypesBean {
this.monthDay = monthDay;
}
public Date getSqlDate() {
return sqlDate;
}
public void setSqlDate(Date sqlDate) {
this.sqlDate = sqlDate;
}
public LocalDate getLocalDate() {
return localDate;
}
@@ -42,6 +42,7 @@ public class TestNewTypes extends BaseTestCase {
bean.setOffsetDateTime(OffsetDateTime.now());
bean.setZonedDateTime(ZonedDateTime.now());
bean.setLocalTime(LocalTime.now());
bean.setSqlDate(java.sql.Date.valueOf("2019-07-21"));
bean.setInstant(Instant.now());
bean.setYear(Year.now());
bean.setMonth(Month.APRIL);
@@ -77,6 +78,9 @@ public class TestNewTypes extends BaseTestCase {
list = DB.find(SomeNewTypesBean.class).where().lt("zonedDateTime", ZonedDateTime.now()).findList();
assertTrue(!list.isEmpty());
list = DB.find(SomeNewTypesBean.class).where().eq("sqlDate", bean.getSqlDate()).findList();
assertTrue(!list.isEmpty());
list = DB.find(SomeNewTypesBean.class).where().le("localTime", LocalTime.now()).findList();
assertTrue(!list.isEmpty());
@@ -113,6 +117,7 @@ public class TestNewTypes extends BaseTestCase {
assertEquals(bean.getZoneOffset(), fetched.getZoneOffset());
assertEquals(bean.getMonth(), fetched.getMonth());
assertEquals(bean.getYear(), fetched.getYear());
assertEquals(bean.getSqlDate(), fetched.getSqlDate());
assertEquals(bean.getYearMonth(), fetched.getYearMonth());
assertEquals(bean.getMonthDay(), fetched.getMonthDay());
assertEquals(bean.getLocalDate(), fetched.getLocalDate());
@@ -121,7 +121,7 @@ public class TestSqlUpdateUpsert extends BaseTestCase {
EPersonOnline found2 = Ebean.find(EPersonOnline.class, key2);
assertThat(found2).isNotNull();
assertThat(found2.getId()).isEqualTo(key);
assertThat(found2.getId().toString()).isEqualTo(key.toString());
assertThat(found2.getEmail()).isEqualTo("bar@one.com");
assertThat(found2.isOnlineStatus()).isFalse();