-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Otavio Santana <[email protected]>
- Loading branch information
1 parent
52598d5
commit 841cbad
Showing
4 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
oracle-nosql/src/main/java/org/jnosql/demo/se/beer/App6.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package org.jnosql.demo.se.beer; | ||
|
||
import jakarta.enterprise.inject.se.SeContainer; | ||
import jakarta.enterprise.inject.se.SeContainerInitializer; | ||
import net.datafaker.Faker; | ||
import org.eclipse.jnosql.mapping.DatabaseQualifier; | ||
|
||
public class App6 { | ||
|
||
public static void main(String[] args) { | ||
var faker = new Faker(); | ||
try (SeContainer container = SeContainerInitializer.newInstance().initialize()) { | ||
|
||
var guest = new Guest(faker.cpf().valid(), faker.name().name()); | ||
var room = new Room(12, guest); | ||
var repository = container.select(Hotel.class, DatabaseQualifier.ofDocument()).get(); | ||
var roomUpdated = repository.checkIn(room); | ||
System.out.println("Room updated: " + roomUpdated); | ||
|
||
} | ||
|
||
System.exit(0); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
oracle-nosql/src/main/java/org/jnosql/demo/se/beer/Guest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package org.jnosql.demo.se.beer; | ||
|
||
import jakarta.nosql.Column; | ||
import jakarta.nosql.Embeddable; | ||
|
||
@Embeddable | ||
public record Guest (@Column String documentNumber, @Column String name) { | ||
} |
26 changes: 26 additions & 0 deletions
26
oracle-nosql/src/main/java/org/jnosql/demo/se/beer/Hotel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package org.jnosql.demo.se.beer; | ||
|
||
import jakarta.data.page.Page; | ||
import jakarta.data.page.PageRequest; | ||
import jakarta.data.repository.By; | ||
import jakarta.data.repository.Delete; | ||
import jakarta.data.repository.Find; | ||
import jakarta.data.repository.Repository; | ||
import jakarta.data.repository.Save; | ||
|
||
import java.util.Optional; | ||
|
||
@Repository | ||
public interface Hotel { | ||
|
||
@Save | ||
Room checkIn(Room room); | ||
|
||
@Delete | ||
void checkOut(Room room); | ||
|
||
@Find | ||
Optional<Room> reservation(@By("_id") String number); | ||
|
||
Page<Room> findBy(PageRequest pageRequest); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package org.jnosql.demo.se.beer; | ||
|
||
import jakarta.nosql.Column; | ||
import jakarta.nosql.Entity; | ||
import jakarta.nosql.Id; | ||
|
||
@Entity | ||
public record Room (@Id int number, @Column Guest guest) { | ||
} |