From a681c0e1d9f2c7cd7e299a6fc4ef2047d0c1b0fe Mon Sep 17 00:00:00 2001 From: Christian Beikov Date: Thu, 4 Aug 2022 12:48:27 +0200 Subject: [PATCH] HHH-15416 Improve error messages when FormatMapper is missing --- .../org/hibernate/internal/FastSessionServices.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/hibernate-core/src/main/java/org/hibernate/internal/FastSessionServices.java b/hibernate-core/src/main/java/org/hibernate/internal/FastSessionServices.java index 387ec5ac47..9f10b9aedd 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/FastSessionServices.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/FastSessionServices.java @@ -16,6 +16,7 @@ import jakarta.persistence.PessimisticLockScope; import org.hibernate.CacheMode; import org.hibernate.FlushMode; +import org.hibernate.HibernateException; import org.hibernate.LockOptions; import org.hibernate.TimeZoneStorageStrategy; import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; @@ -374,10 +375,20 @@ public final class FastSessionServices { } public FormatMapper getJsonFormatMapper() { + if ( jsonFormatMapper == null ) { + throw new HibernateException( + "Could not find a FormatMapper for the JSON format, which is required for mapping JSON types. JSON FormatMapper configuration is automatic, but requires that you have either Jackson or a JSONB implementation like Yasson on the class path." + ); + } return jsonFormatMapper; } public FormatMapper getXmlFormatMapper() { + if ( xmlFormatMapper == null ) { + throw new HibernateException( + "Could not find a FormatMapper for the XML format, which is required for mapping XML types. XML FormatMapper configuration is automatic, but requires that you have either Jackson XML or a JAXB implementation like Glassfish JAXB on the class path." + ); + } return xmlFormatMapper; } }