[JAVA-15469] (#12979)
Co-authored-by: panagiotiskakos <panagiotis.kakos@libra-is.com>
This commit is contained in:
		
							parent
							
								
									fefc0d88e0
								
							
						
					
					
						commit
						2495e6f101
					
				| @ -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<Map<String, Object>>() {}); | ||||
|     } | ||||
| 
 | ||||
| } | ||||
|  | ||||
| @ -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<Map<String, Object>, String> { | ||||
| @ -36,7 +38,7 @@ public class HashMapConverter implements AttributeConverter<Map<String, Object>, | ||||
| 
 | ||||
|         Map<String, Object> customerInfo = null; | ||||
|         try { | ||||
|             customerInfo = objectMapper.readValue(customerInfoJSON, Map.class); | ||||
|             customerInfo = objectMapper.readValue(customerInfoJSON, new TypeReference<HashMap<String, Object>>() {}); | ||||
|         } catch (final IOException e) { | ||||
|             logger.error("JSON reading error", e); | ||||
|         } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user