HHH-12586 - Fix CI failure with column names on postgres.
This commit is contained in:
parent
5919000dc8
commit
367cc4c33d
|
@ -14,6 +14,7 @@ import java.time.LocalDateTime;
|
||||||
import java.time.LocalTime;
|
import java.time.LocalTime;
|
||||||
|
|
||||||
import javax.persistence.AttributeConverter;
|
import javax.persistence.AttributeConverter;
|
||||||
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Convert;
|
import javax.persistence.Convert;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.GeneratedValue;
|
import javax.persistence.GeneratedValue;
|
||||||
|
@ -33,19 +34,19 @@ import static org.junit.Assert.assertEquals;
|
||||||
public class JdbcSqlTypeDescriptorConverterTest extends BaseEntityManagerFunctionalTestCase {
|
public class JdbcSqlTypeDescriptorConverterTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
@Override
|
@Override
|
||||||
protected Class<?>[] getAnnotatedClasses() {
|
protected Class<?>[] getAnnotatedClasses() {
|
||||||
return new Class<?>[] { JavaTime.class };
|
return new Class<?>[] { JavaTimeBean.class };
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestForIssue(jiraKey = "HHH-12586")
|
@TestForIssue(jiraKey = "HHH-12586")
|
||||||
public void testJavaTimeStuff() {
|
public void testJava8TimeObjectsUsingJdbcSqlTypeDescriptors() {
|
||||||
// Because some databases do not support millisecond values in timestamps, we clear it here.
|
// Because some databases do not support millisecond values in timestamps, we clear it here.
|
||||||
// This will serve sufficient for our test to verify that the retrieved values match persisted.
|
// This will serve sufficient for our test to verify that the retrieved values match persisted.
|
||||||
LocalDateTime now = LocalDateTime.now().withNano( 0 );
|
LocalDateTime now = LocalDateTime.now().withNano( 0 );
|
||||||
|
|
||||||
// persist the record.
|
// persist the record.
|
||||||
Integer rowId = doInJPA( this::entityManagerFactory, entityManager -> {
|
Integer rowId = doInJPA( this::entityManagerFactory, entityManager -> {
|
||||||
JavaTime javaTime = new JavaTime();
|
JavaTimeBean javaTime = new JavaTimeBean();
|
||||||
javaTime.setLocalDate( now.toLocalDate() );
|
javaTime.setLocalDate( now.toLocalDate() );
|
||||||
javaTime.setLocalTime( now.toLocalTime() );
|
javaTime.setLocalTime( now.toLocalTime() );
|
||||||
javaTime.setLocalDateTime( now );
|
javaTime.setLocalDateTime( now );
|
||||||
|
@ -55,26 +56,29 @@ public class JdbcSqlTypeDescriptorConverterTest extends BaseEntityManagerFunctio
|
||||||
|
|
||||||
// retrieve the record and verify values.
|
// retrieve the record and verify values.
|
||||||
doInJPA( this::entityManagerFactory, entityManager -> {
|
doInJPA( this::entityManagerFactory, entityManager -> {
|
||||||
final JavaTime javaTime = entityManager.find( JavaTime.class, rowId );
|
final JavaTimeBean javaTime = entityManager.find( JavaTimeBean.class, rowId );
|
||||||
assertEquals( now.toLocalDate(), javaTime.getLocalDate() );
|
assertEquals( now.toLocalDate(), javaTime.getLocalDate() );
|
||||||
assertEquals( now.toLocalTime(), javaTime.getLocalTime() );
|
assertEquals( now.toLocalTime(), javaTime.getLocalTime() );
|
||||||
assertEquals( now, javaTime.getLocalDateTime() );
|
assertEquals( now, javaTime.getLocalDateTime() );
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Entity(name = "JavaTime")
|
@Entity(name = "JavaTimeBean")
|
||||||
public static class JavaTime {
|
public static class JavaTimeBean {
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue
|
@GeneratedValue
|
||||||
private Integer id;
|
private Integer id;
|
||||||
|
|
||||||
@Convert(converter = LocalDateToDateConverter.class)
|
@Convert(converter = LocalDateToDateConverter.class)
|
||||||
|
@Column(name = "LDATE")
|
||||||
private LocalDate localDate;
|
private LocalDate localDate;
|
||||||
|
|
||||||
@Convert(converter = LocalTimeToTimeConverter.class)
|
@Convert(converter = LocalTimeToTimeConverter.class)
|
||||||
|
@Column(name = "LTIME" )
|
||||||
private LocalTime localTime;
|
private LocalTime localTime;
|
||||||
|
|
||||||
@Convert(converter = LocalDateTimeToTimestampConverter.class)
|
@Convert(converter = LocalDateTimeToTimestampConverter.class)
|
||||||
|
@Column(name = "LDATETIME")
|
||||||
private LocalDateTime localDateTime;
|
private LocalDateTime localDateTime;
|
||||||
|
|
||||||
public Integer getId() {
|
public Integer getId() {
|
||||||
|
|
Loading…
Reference in New Issue