From 0842ff8c5671d9ccf679e966c8f6dbcb1458d63c Mon Sep 17 00:00:00 2001 From: Jens Schauder Date: Wed, 22 Sep 2021 13:19:05 +0200 Subject: [PATCH] Remove ThreeTenBackPort support. Closes #2311 --- pom.xml | 3 +- .../ThreeTenBackPortJpaConverters.java | 127 ------------------ .../convert/threetenbp/DateTimeSample.java | 41 ------ ...BackPortJpaConvertersIntegrationTests.java | 84 ------------ 4 files changed, 2 insertions(+), 253 deletions(-) delete mode 100644 src/main/java/org/springframework/data/jpa/convert/threetenbp/ThreeTenBackPortJpaConverters.java delete mode 100644 src/test/java/org/springframework/data/jpa/convert/threetenbp/DateTimeSample.java delete mode 100644 src/test/java/org/springframework/data/jpa/convert/threetenbp/ThreeTenBackPortJpaConvertersIntegrationTests.java diff --git a/pom.xml b/pom.xml index 906fa1e40..c02ae0f6f 100644 --- a/pom.xml +++ b/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 diff --git a/src/main/java/org/springframework/data/jpa/convert/threetenbp/ThreeTenBackPortJpaConverters.java b/src/main/java/org/springframework/data/jpa/convert/threetenbp/ThreeTenBackPortJpaConverters.java deleted file mode 100644 index 8aa31ce11..000000000 --- a/src/main/java/org/springframework/data/jpa/convert/threetenbp/ThreeTenBackPortJpaConverters.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright 2015-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.data.jpa.convert.threetenbp; - -import java.util.Date; - -import javax.persistence.AttributeConverter; -import javax.persistence.Converter; - -import org.springframework.data.convert.ThreeTenBackPortConverters.DateToInstantConverter; -import org.springframework.data.convert.ThreeTenBackPortConverters.DateToLocalDateConverter; -import org.springframework.data.convert.ThreeTenBackPortConverters.DateToLocalDateTimeConverter; -import org.springframework.data.convert.ThreeTenBackPortConverters.DateToLocalTimeConverter; -import org.springframework.data.convert.ThreeTenBackPortConverters.InstantToDateConverter; -import org.springframework.data.convert.ThreeTenBackPortConverters.LocalDateTimeToDateConverter; -import org.springframework.data.convert.ThreeTenBackPortConverters.LocalDateToDateConverter; -import org.springframework.data.convert.ThreeTenBackPortConverters.LocalTimeToDateConverter; -import org.springframework.data.convert.ThreeTenBackPortConverters.StringToZoneIdConverter; -import org.springframework.data.convert.ThreeTenBackPortConverters.ZoneIdToStringConverter; -import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; -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; - -/** - * JPA 2.1 converters to turn ThreeTen back port types into legacy {@link Date}s. To activate these converters make sure - * your persistence provider detects them by including this class in the list of mapped classes. In Spring environments, - * you can simply register the package of this class (i.e. {@code org.springframework.data.jpa.convert.threetenbp}) as - * package to be scanned on e.g. the {@link LocalContainerEntityManagerFactoryBean}. - * - * @author Oliver Gierke - * @see https://www.threeten.org/threetenbp - * @since 1.8 - * @deprecated since 2.4, use JSR-310 types as replacement for ThreeTenBackport. - */ -public class ThreeTenBackPortJpaConverters { - - @Converter(autoApply = true) - @Deprecated - public static class LocalDateConverter implements AttributeConverter { - - @Override - public Date convertToDatabaseColumn(LocalDate date) { - return LocalDateToDateConverter.INSTANCE.convert(date); - } - - @Override - public LocalDate convertToEntityAttribute(Date date) { - return DateToLocalDateConverter.INSTANCE.convert(date); - } - } - - @Converter(autoApply = true) - @Deprecated - public static class LocalTimeConverter implements AttributeConverter { - - @Override - public Date convertToDatabaseColumn(LocalTime time) { - return LocalTimeToDateConverter.INSTANCE.convert(time); - } - - @Override - public LocalTime convertToEntityAttribute(Date date) { - return DateToLocalTimeConverter.INSTANCE.convert(date); - } - } - - @Converter(autoApply = true) - @Deprecated - public static class LocalDateTimeConverter implements AttributeConverter { - - @Override - public Date convertToDatabaseColumn(LocalDateTime date) { - return LocalDateTimeToDateConverter.INSTANCE.convert(date); - } - - @Override - public LocalDateTime convertToEntityAttribute(Date date) { - return DateToLocalDateTimeConverter.INSTANCE.convert(date); - } - } - - @Converter(autoApply = true) - @Deprecated - public static class InstantConverter implements AttributeConverter { - - @Override - public Date convertToDatabaseColumn(Instant instant) { - return InstantToDateConverter.INSTANCE.convert(instant); - } - - @Override - public Instant convertToEntityAttribute(Date date) { - return DateToInstantConverter.INSTANCE.convert(date); - } - } - - @Converter(autoApply = true) - @Deprecated - public static class ZoneIdConverter implements AttributeConverter { - - @Override - public String convertToDatabaseColumn(ZoneId zoneId) { - return ZoneIdToStringConverter.INSTANCE.convert(zoneId); - } - - @Override - public ZoneId convertToEntityAttribute(String zoneId) { - return StringToZoneIdConverter.INSTANCE.convert(zoneId); - } - } -} diff --git a/src/test/java/org/springframework/data/jpa/convert/threetenbp/DateTimeSample.java b/src/test/java/org/springframework/data/jpa/convert/threetenbp/DateTimeSample.java deleted file mode 100644 index 482632780..000000000 --- a/src/test/java/org/springframework/data/jpa/convert/threetenbp/DateTimeSample.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2014-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.data.jpa.convert.threetenbp; - -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.Id; - -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 - */ -@Entity -public class DateTimeSample { - - @Id @GeneratedValue Long id; - - Instant instant; - LocalDate localDate; - LocalTime localTime; - LocalDateTime localDateTime; - ZoneId zoneId; -} diff --git a/src/test/java/org/springframework/data/jpa/convert/threetenbp/ThreeTenBackPortJpaConvertersIntegrationTests.java b/src/test/java/org/springframework/data/jpa/convert/threetenbp/ThreeTenBackPortJpaConvertersIntegrationTests.java deleted file mode 100644 index 93e91f6d5..000000000 --- a/src/test/java/org/springframework/data/jpa/convert/threetenbp/ThreeTenBackPortJpaConvertersIntegrationTests.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright 2015-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.data.jpa.convert.threetenbp; - -import static org.assertj.core.api.Assertions.*; -import static org.junit.Assume.*; -import static org.springframework.data.jpa.support.EntityManagerTestUtils.*; - -import javax.persistence.EntityManager; -import javax.persistence.PersistenceContext; - -import org.junit.jupiter.api.Test; -import org.springframework.context.annotation.Configuration; -import org.springframework.data.jpa.domain.support.AbstractAttributeConverterIntegrationTests; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.transaction.annotation.Transactional; -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}. - * - * @author Oliver Gierke - * @author Jens Schauder - * @since 1.8 - */ -@ContextConfiguration -@Transactional -public class ThreeTenBackPortJpaConvertersIntegrationTests extends AbstractAttributeConverterIntegrationTests { - - @PersistenceContext EntityManager em; - - @Test // DATAJPA-650 - void usesThreeTenBackPortJpaConverters() { - - assumeTrue(currentEntityManagerIsAJpa21EntityManager(em)); - - DateTimeSample sample = new DateTimeSample(); - - sample.instant = Instant.now(); - sample.localDate = LocalDate.now(); - sample.localTime = LocalTime.now(); - sample.localDateTime = LocalDateTime.now(); - sample.zoneId = ZoneId.of("Europe/Berlin"); - - em.persist(sample); - em.flush(); - em.clear(); - - DateTimeSample result = em.find(DateTimeSample.class, sample.id); - - assertThat(result).isNotNull(); - assertThat(result.instant).isEqualTo(sample.instant); - assertThat(result.localDate).isEqualTo(sample.localDate); - assertThat(result.localTime).isEqualTo(sample.localTime); - assertThat(result.localDateTime).isEqualTo(sample.localDateTime); - assertThat(result.zoneId).isEqualTo(sample.zoneId); - } - - @Configuration - static class Config extends InfrastructureConfig { - - @Override - protected String getPackageName() { - return getClass().getPackage().getName(); - } - } -}