From dc2648280a15edeed1f57070a55250c7c293b939 Mon Sep 17 00:00:00 2001 From: Vlad Mihalcea Date: Wed, 3 Aug 2022 21:50:45 +0300 Subject: [PATCH] HibernateTypesContributor throws java.lang.NoClassDefFoundError: javax/money/MonetaryAmount #468 --- .../hibernate/type/HibernateTypesContributor.java | 5 ++++- .../hibernate/type/HibernateTypesContributor.java | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/hibernate-types-52/src/main/java/com/vladmihalcea/hibernate/type/HibernateTypesContributor.java b/hibernate-types-52/src/main/java/com/vladmihalcea/hibernate/type/HibernateTypesContributor.java index fc645a65e..3a405971c 100644 --- a/hibernate-types-52/src/main/java/com/vladmihalcea/hibernate/type/HibernateTypesContributor.java +++ b/hibernate-types-52/src/main/java/com/vladmihalcea/hibernate/type/HibernateTypesContributor.java @@ -94,9 +94,12 @@ public void contribute(TypeContributions typeContributions, ServiceRegistry serv .contributeType(typeContributions, YearMonthEpochType.INSTANCE) .contributeType(typeContributions, YearMonthIntegerType.INSTANCE) .contributeType(typeContributions, YearMonthTimestampType.INSTANCE) - .contributeType(typeContributions, MonetaryAmountType.INSTANCE) /* JSON */ .contributeType(typeContributions, JsonType.INSTANCE); + /* Money and Currency API */ + if(ReflectionUtils.getClassOrNull("org.javamoney.moneta.Money") != null) { + this.contributeType(typeContributions, MonetaryAmountType.INSTANCE); + } } private HibernateTypesContributor contributeType(TypeContributions typeContributions, Object type) { diff --git a/hibernate-types-55/src/main/java/com/vladmihalcea/hibernate/type/HibernateTypesContributor.java b/hibernate-types-55/src/main/java/com/vladmihalcea/hibernate/type/HibernateTypesContributor.java index fc645a65e..3a405971c 100644 --- a/hibernate-types-55/src/main/java/com/vladmihalcea/hibernate/type/HibernateTypesContributor.java +++ b/hibernate-types-55/src/main/java/com/vladmihalcea/hibernate/type/HibernateTypesContributor.java @@ -94,9 +94,12 @@ public void contribute(TypeContributions typeContributions, ServiceRegistry serv .contributeType(typeContributions, YearMonthEpochType.INSTANCE) .contributeType(typeContributions, YearMonthIntegerType.INSTANCE) .contributeType(typeContributions, YearMonthTimestampType.INSTANCE) - .contributeType(typeContributions, MonetaryAmountType.INSTANCE) /* JSON */ .contributeType(typeContributions, JsonType.INSTANCE); + /* Money and Currency API */ + if(ReflectionUtils.getClassOrNull("org.javamoney.moneta.Money") != null) { + this.contributeType(typeContributions, MonetaryAmountType.INSTANCE); + } } private HibernateTypesContributor contributeType(TypeContributions typeContributions, Object type) {