From cd51e118df520c67f9e2c58b13c3c1bfca494d82 Mon Sep 17 00:00:00 2001 From: Michele Guarnaccia Date: Mon, 18 May 2020 19:15:18 +0200 Subject: [PATCH] Fixed compilation error --- .../src/main/java/com/baeldung/model/CustomerDto.java | 4 ++++ .../src/main/java/com/baeldung/service/CustomerService.java | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/model/CustomerDto.java b/persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/model/CustomerDto.java index c4601d5b81..74b909aad8 100644 --- a/persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/model/CustomerDto.java +++ b/persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/model/CustomerDto.java @@ -17,6 +17,10 @@ public class CustomerDto { this.phone = c.phone; } + public long getId() { + return this.id; + } + public Customer convertToEntity() { Customer c = new Customer(); c.id = id; diff --git a/persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/service/CustomerService.java b/persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/service/CustomerService.java index 3101cd8ece..9ebbb0c814 100644 --- a/persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/service/CustomerService.java +++ b/persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/service/CustomerService.java @@ -38,7 +38,7 @@ public class CustomerService { } public Customer updateCustomer(CustomerDto dto) { - Customer myCustomer = repo.findById(dto.id); + Customer myCustomer = repo.findById(dto.getId()); mapper.updateCustomerFromDto(dto, myCustomer); repo.save(myCustomer); return myCustomer;