This is an automated email from the ASF dual-hosted git repository.
ahuber pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/causeway.git
The following commit(s) were added to refs/heads/main by this push:
new 8ebf3c7e6b6 CAUSEWAY-3868: [Persistence] adds JPA java.util.Local
support
8ebf3c7e6b6 is described below
commit 8ebf3c7e6b65bd6299fdaf5afb1cfb92f850bf1f
Author: Andi Huber <[email protected]>
AuthorDate: Fri Mar 14 22:23:32 2025 +0100
CAUSEWAY-3868: [Persistence] adds JPA java.util.Local support
---
.../CausewayModulePersistenceJpaIntegration.java | 2 +
.../java/util/JavaUtilLocaleConverter.java | 46 ++++++++++++++++++++++
2 files changed, 48 insertions(+)
diff --git
a/persistence/jpa/integration/src/main/java/org/apache/causeway/persistence/jpa/integration/CausewayModulePersistenceJpaIntegration.java
b/persistence/jpa/integration/src/main/java/org/apache/causeway/persistence/jpa/integration/CausewayModulePersistenceJpaIntegration.java
index fff16c18d5b..64992220cae 100644
---
a/persistence/jpa/integration/src/main/java/org/apache/causeway/persistence/jpa/integration/CausewayModulePersistenceJpaIntegration.java
+++
b/persistence/jpa/integration/src/main/java/org/apache/causeway/persistence/jpa/integration/CausewayModulePersistenceJpaIntegration.java
@@ -34,6 +34,7 @@
import
org.apache.causeway.persistence.jpa.integration.typeconverters.java.time.OffsetDateTimeConverterForJpa;
import
org.apache.causeway.persistence.jpa.integration.typeconverters.java.time.OffsetTimeConverterForJpa;
import
org.apache.causeway.persistence.jpa.integration.typeconverters.java.time.ZonedDateTimeConverterForJpa;
+import
org.apache.causeway.persistence.jpa.integration.typeconverters.java.util.JavaUtilLocaleConverter;
import
org.apache.causeway.persistence.jpa.integration.typeconverters.java.util.JavaUtilUuidConverter;
import
org.apache.causeway.persistence.jpa.integration.typeconverters.schema.v2.CausewayChangesDtoConverter;
import
org.apache.causeway.persistence.jpa.integration.typeconverters.schema.v2.CausewayCommandDtoConverter;
@@ -67,6 +68,7 @@
CausewayInteractionDtoConverter.class,
CausewayOidDtoConverter.class,
JavaAwtBufferedImageByteArrayConverter.class,
+ JavaUtilLocaleConverter.class,
JavaUtilUuidConverter.class,
OffsetTimeConverterForJpa.class,
OffsetDateTimeConverterForJpa.class,
diff --git
a/persistence/jpa/integration/src/main/java/org/apache/causeway/persistence/jpa/integration/typeconverters/java/util/JavaUtilLocaleConverter.java
b/persistence/jpa/integration/src/main/java/org/apache/causeway/persistence/jpa/integration/typeconverters/java/util/JavaUtilLocaleConverter.java
new file mode 100644
index 00000000000..bd4c8f2cc16
--- /dev/null
+++
b/persistence/jpa/integration/src/main/java/org/apache/causeway/persistence/jpa/integration/typeconverters/java/util/JavaUtilLocaleConverter.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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
+ *
+ * http://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.apache.causeway.persistence.jpa.integration.typeconverters.java.util;
+
+import java.util.Locale;
+import jakarta.persistence.AttributeConverter;
+import jakarta.persistence.Converter;
+
+/**
+ * @since 3.3 {@index}
+ */
+@Converter(autoApply = true)
+public class JavaUtilLocaleConverter
+implements AttributeConverter<Locale, String> {
+
+ @Override
+ public String convertToDatabaseColumn(final Locale locale) {
+ return locale != null
+ ? locale.toLanguageTag()
+ : null;
+ }
+
+ @Override
+ public Locale convertToEntityAttribute(final String datastoreValue) {
+ return datastoreValue != null
+ ? Locale.forLanguageTag(datastoreValue)
+ : null;
+ }
+
+}