---
title: "Rainer Scholz (@rainer619) | Hashnode"
description: "Rainer Scholz (@rainer619) writes on Hashnode. Read their latest articles and follow their work."
url: "https://hashnode.com/@rainer619"
---

@rainer619

# Rainer Scholz

@rainer619 · Joined September 2022

## Comments

[Hi Maddy, I wonder how an public CustomerDTO updateCustomer(CustomerDTO customerDTO) would be implemented by you? My straight forward solution would be: public CustomerDTO updateCustomer(CustomerDTO customerDTO) { Customer customer = customerRepository.getReferenceById(customerDTO.getId()); customer.setFirstName(customerDTO.getFirstName()); customer.setLastName(customerDTO.getLastName()); // ... repeated for all fields customerRepository.save(customer); } Note: The CustomerDTO requires some kind of resource identifier. I used the primary key of the database table.](https://hashnode.com/posts/replace-persistence-entity-with-a-dto-object/6294a0244dbee2dc251e3843/comment/631b4a3df73f4734bc0517e8)

Comment · Article · Sep 9, 2022 · [Replace a JPA entity with a DTO](https://hashnode.com/posts/replace-persistence-entity-with-a-dto-object/6294a0244dbee2dc251e3843)
