From f1997a3f381abf533c0ae52b109b638ebfea1924 Mon Sep 17 00:00:00 2001 From: George Panaretos Date: Mon, 2 Jan 2023 19:47:54 +0100 Subject: [PATCH] Clean up application run source Remove the comment section and also the for loop and replacing it likewise with the findByLastname fetching method --- .../accessingdatajpa/AccessingDataJpaApplication.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/complete/src/main/java/com/example/accessingdatajpa/AccessingDataJpaApplication.java b/complete/src/main/java/com/example/accessingdatajpa/AccessingDataJpaApplication.java index be1a0d8..95adede 100644 --- a/complete/src/main/java/com/example/accessingdatajpa/AccessingDataJpaApplication.java +++ b/complete/src/main/java/com/example/accessingdatajpa/AccessingDataJpaApplication.java @@ -29,9 +29,9 @@ public CommandLineRunner demo(CustomerRepository repository) { // fetch all customers log.info("Customers found with findAll():"); log.info("-------------------------------"); - for (Customer customer : repository.findAll()) { + repository.findAll().forEach(customer -> { log.info(customer.toString()); - } + }); log.info(""); // fetch an individual customer by ID @@ -47,9 +47,6 @@ public CommandLineRunner demo(CustomerRepository repository) { repository.findByLastName("Bauer").forEach(bauer -> { log.info(bauer.toString()); }); - // for (Customer bauer : repository.findByLastName("Bauer")) { - // log.info(bauer.toString()); - // } log.info(""); }; }