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() { }