Corrige mapeo de tipo de dato

main
Freddy Heredia 2 years ago
parent bfaad9af8e
commit fe74130562

@ -16,6 +16,9 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
@RestController
@RequestMapping("/api/producto")
@CrossOrigin({"*"})
@ -65,7 +68,9 @@ public class ProductoController {
try {
Field campoEntidad = Producto.class.getDeclaredField(fieldName);
campoEntidad.setAccessible(true);
campoEntidad.set(producto, fieldValue);
ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new JavaTimeModule());
campoEntidad.set(producto, mapper.convertValue(fieldValue, campoEntidad.getType()));
} catch (NoSuchFieldException | IllegalAccessException ex) {
// maneja la excepción si ocurre algún error al acceder al campo
}

Loading…
Cancel
Save