Skip to content

Commit

Permalink
refactor: update structre
Browse files Browse the repository at this point in the history
Signed-off-by: Otavio Santana <[email protected]>
  • Loading branch information
otaviojava committed Feb 1, 2024
1 parent 89b4c46 commit 9474fb1
Show file tree
Hide file tree
Showing 10 changed files with 86 additions and 15 deletions.
44 changes: 44 additions & 0 deletions oracle-nosql/src/main/java/org/jnosql/demo/se/beer/App.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Copyright (c) 2024 Contributors to the Eclipse Foundation
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Apache License v2.0 which accompanies this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php.
*
* You may elect to redistribute this code under either of these licenses.
*/
package org.jnosql.demo.se.beer;



import jakarta.data.Sort;
import jakarta.data.page.Page;
import jakarta.data.page.Pageable;
import jakarta.enterprise.inject.se.SeContainer;
import jakarta.enterprise.inject.se.SeContainerInitializer;
import net.datafaker.Faker;
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();
for (int index = 0; index < 100; index++) {
Beer beer = Beer.of(faker);
repository.save(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);
}
}
private App() {
}
}
34 changes: 34 additions & 0 deletions oracle-nosql/src/main/java/org/jnosql/demo/se/beer/App2.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright (c) 2024 Contributors to the Eclipse Foundation
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Apache License v2.0 which accompanies this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php.
*
* You may elect to redistribute this code under either of these licenses.
*/
package org.jnosql.demo.se.beer;

import jakarta.enterprise.inject.se.SeContainer;
import jakarta.enterprise.inject.se.SeContainerInitializer;
import jakarta.nosql.keyvalue.KeyValueTemplate;
import net.datafaker.Faker;

public class App2 {

public static void main(String[] args) {
Faker faker = new Faker();
try (SeContainer container = SeContainerInitializer.newInstance().initialize()) {
KeyValueTemplate template = container.select(KeyValueTemplate.class).get();
Beer beer = Beer.of(faker);
template.put(beer);


System.out.println("The query result: " + template.get(beer.id(), Beer.class));
template.delete(beer.id());
System.out.println("The query result: " + template.get(beer.id(), Beer.class));
}
System.exit(0);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
* Otavio Santana
*/
package org.jnosql.demo.se;
package org.jnosql.demo.se.beer;


import jakarta.nosql.Column;
Expand All @@ -23,11 +23,7 @@
import java.util.Objects;
import java.util.UUID;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;




@Entity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
* Otavio Santana
*/
package org.jnosql.demo.se;
package org.jnosql.demo.se.beer;

import java.util.Set;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
* Otavio Santana
*/
package org.jnosql.demo.se;
package org.jnosql.demo.se.beer;



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* You may elect to redistribute this code under either of these licenses.
*/

package org.jnosql.demo.se;
package org.jnosql.demo.se.car;

import jakarta.enterprise.inject.se.SeContainer;
import jakarta.enterprise.inject.se.SeContainerInitializer;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package org.jnosql.demo.se;
package org.jnosql.demo.se.car;


import jakarta.data.Sort;
import jakarta.data.page.Page;
import jakarta.data.page.Pageable;
import jakarta.enterprise.inject.se.SeContainer;
import jakarta.enterprise.inject.se.SeContainerInitializer;
import jakarta.nosql.keyvalue.KeyValueTemplate;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.jnosql.demo.se;
package org.jnosql.demo.se.car;


import jakarta.data.Sort;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.jnosql.demo.se;
package org.jnosql.demo.se.car;

import jakarta.nosql.Column;
import jakarta.nosql.Entity;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.jnosql.demo.se;
package org.jnosql.demo.se.car;

import jakarta.data.page.Page;
import jakarta.data.page.Pageable;
Expand Down

0 comments on commit 9474fb1

Please sign in to comment.