Skip to content

Commit

Permalink
feat: update oracle nosql using template
Browse files Browse the repository at this point in the history
Signed-off-by: Otavio Santana <[email protected]>
  • Loading branch information
otaviojava committed Feb 12, 2024
1 parent a9993df commit 9104fea
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions oracle-nosql/src/main/java/org/jnosql/demo/se/beer/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<Beer> 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<Beer> 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() {
}
Expand Down

0 comments on commit 9104fea

Please sign in to comment.