DATAJPA-808 - Introduced AttributeConverters for ZoneId for JSR-310 and ThreeTenBP.

This commit is contained in:
Oliver Gierke
2015-10-05 18:39:34 +02:00
parent dddadd4547
commit 945acce07d
6 changed files with 42 additions and 0 deletions

View File

@@ -19,6 +19,7 @@ import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.ZoneId;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
@@ -35,4 +36,5 @@ public class DateTimeSample {
LocalDate localDate;
LocalTime localTime;
LocalDateTime localDateTime;
ZoneId zoneId;
}

View File

@@ -24,6 +24,7 @@ import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.ZoneId;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
@@ -68,6 +69,7 @@ public class Jsr310JpaConvertersIntegrationTests extends AbstractAttributeConver
sample.localDate = LocalDate.now();
sample.localTime = LocalTime.now();
sample.localDateTime = LocalDateTime.now();
sample.zoneId = ZoneId.of("Europe/Berlin");
em.persist(sample);
em.flush();
@@ -80,5 +82,6 @@ public class Jsr310JpaConvertersIntegrationTests extends AbstractAttributeConver
assertThat(result.localDate, is(sample.localDate));
assertThat(result.localTime, is(sample.localTime));
assertThat(result.localDateTime, is(sample.localDateTime));
assertThat(result.zoneId, is(sample.zoneId));
}
}

View File

@@ -23,6 +23,7 @@ import org.threeten.bp.Instant;
import org.threeten.bp.LocalDate;
import org.threeten.bp.LocalDateTime;
import org.threeten.bp.LocalTime;
import org.threeten.bp.ZoneId;
/**
* @author Oliver Gierke
@@ -36,4 +37,5 @@ public class DateTimeSample {
LocalDate localDate;
LocalTime localTime;
LocalDateTime localDateTime;
ZoneId zoneId;
}

View File

@@ -32,6 +32,7 @@ import org.threeten.bp.Instant;
import org.threeten.bp.LocalDate;
import org.threeten.bp.LocalDateTime;
import org.threeten.bp.LocalTime;
import org.threeten.bp.ZoneId;
/**
* Integration tests for {@link ThreeTenBackPortJpaConverters}.
@@ -68,6 +69,7 @@ public class ThreeTenBackPortJpaConvertersIntegrationTests extends AbstractAttri
sample.localDate = LocalDate.now();
sample.localTime = LocalTime.now();
sample.localDateTime = LocalDateTime.now();
sample.zoneId = ZoneId.of("Europe/Berlin");
em.persist(sample);
em.flush();
@@ -80,5 +82,6 @@ public class ThreeTenBackPortJpaConvertersIntegrationTests extends AbstractAttri
assertThat(result.localDate, is(sample.localDate));
assertThat(result.localTime, is(sample.localTime));
assertThat(result.localDateTime, is(sample.localDateTime));
assertThat(result.zoneId, is(sample.zoneId));
}
}