diff --git a/persistence-modules/hibernate5/src/main/java/com/baeldung/hibernate/persistjson/Customer.java b/persistence-modules/hibernate5/src/main/java/com/baeldung/hibernate/persistjson/Customer.java index 6bd1c24869..3e214d58f9 100644 --- a/persistence-modules/hibernate5/src/main/java/com/baeldung/hibernate/persistjson/Customer.java +++ b/persistence-modules/hibernate5/src/main/java/com/baeldung/hibernate/persistjson/Customer.java @@ -9,6 +9,7 @@ import javax.persistence.Id; import javax.persistence.Table; import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; @Entity @@ -74,7 +75,7 @@ public class Customer { } public void deserializeCustomerAttributes() throws IOException { - this.customerAttributes = objectMapper.readValue(customerAttributeJSON, Map.class); + this.customerAttributes = objectMapper.readValue(customerAttributeJSON, new TypeReference>() {}); } } diff --git a/persistence-modules/hibernate5/src/main/java/com/baeldung/hibernate/persistjson/HashMapConverter.java b/persistence-modules/hibernate5/src/main/java/com/baeldung/hibernate/persistjson/HashMapConverter.java index b1c2d50480..5f3482b36f 100644 --- a/persistence-modules/hibernate5/src/main/java/com/baeldung/hibernate/persistjson/HashMapConverter.java +++ b/persistence-modules/hibernate5/src/main/java/com/baeldung/hibernate/persistjson/HashMapConverter.java @@ -1,6 +1,7 @@ package com.baeldung.hibernate.persistjson; import java.io.IOException; +import java.util.HashMap; import java.util.Map; import javax.persistence.AttributeConverter; @@ -10,6 +11,7 @@ import org.slf4j.LoggerFactory; import com.baeldung.hibernate.interceptors.CustomInterceptor; import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; public class HashMapConverter implements AttributeConverter, String> { @@ -36,7 +38,7 @@ public class HashMapConverter implements AttributeConverter, Map customerInfo = null; try { - customerInfo = objectMapper.readValue(customerInfoJSON, Map.class); + customerInfo = objectMapper.readValue(customerInfoJSON, new TypeReference>() {}); } catch (final IOException e) { logger.error("JSON reading error", e); }