From 9104fea941241c54654f2643e4e711f1dd3c04b9 Mon Sep 17 00:00:00 2001 From: Otavio Santana Date: Mon, 12 Feb 2024 11:40:23 +0000 Subject: [PATCH] feat: update oracle nosql using template Signed-off-by: Otavio Santana --- .../java/org/jnosql/demo/se/beer/App.java | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/oracle-nosql/src/main/java/org/jnosql/demo/se/beer/App.java b/oracle-nosql/src/main/java/org/jnosql/demo/se/beer/App.java index 1da33899..19449090 100644 --- a/oracle-nosql/src/main/java/org/jnosql/demo/se/beer/App.java +++ b/oracle-nosql/src/main/java/org/jnosql/demo/se/beer/App.java @@ -17,27 +17,32 @@ import jakarta.data.page.Pageable; import jakarta.enterprise.inject.se.SeContainer; import jakarta.enterprise.inject.se.SeContainerInitializer; +import jakarta.nosql.document.DocumentTemplate; import net.datafaker.Faker; +import org.jnosql.demo.se.car.Car; + public class App { public static void main(String[] args) { Faker faker = new Faker(); try (SeContainer container = SeContainerInitializer.newInstance().initialize()) { - BeerRepository repository = container.select(BeerRepository.class).get(); + DocumentTemplate template = container.select(DocumentTemplate.class).get(); for (int index = 0; index < 100; index++) { Beer beer = Beer.of(faker); - repository.save(beer); + template.insert(beer); } - Pageable page = Pageable.ofPage(1).sortBy(Sort.desc("style")); - Page page1 = repository.findAll(page); - System.out.println("The first page"); - page1.forEach(System.out::println); - System.out.println("The second page"); - Pageable secondPage = page.next(); - Page page2 = repository.findAll(secondPage); - page2.forEach(System.out::println); - System.out.println("The query result: "); - repository.query().forEach(System.out::println); + + template.select(Beer.class).stream().toList().forEach(System.out::println); + + System.out.println("Selecting malt by Chocolate"); + template.select(Beer.class).where("malt").eq("Chocolate").orderBy("malt").desc() + .stream().forEach(System.out::println); + + System.out.println("Selecting style by Stout"); + template.select(Beer.class).where("style").eq("Stout").orderBy("malt").desc() + .stream().forEach(System.out::println); } + + System.exit(0); } private App() { }