-
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.
feat: update sample using car instead of beer
Signed-off-by: Otavio Santana <[email protected]>
- Loading branch information
1 parent
1676788
commit 86566f7
Showing
7 changed files
with
127 additions
and
115 deletions.
There are no files selected for viewing
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
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
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
This file was deleted.
Oops, something went wrong.
17 changes: 0 additions & 17 deletions
17
oracle-nosql/src/main/java/org/jnosql/demo/se/BeerRepository.java
This file was deleted.
Oops, something went wrong.
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,86 @@ | ||
package org.jnosql.demo.se; | ||
|
||
import jakarta.nosql.Column; | ||
import jakarta.nosql.Entity; | ||
import jakarta.nosql.Id; | ||
import net.datafaker.Faker; | ||
import net.datafaker.providers.base.Vehicle; | ||
|
||
import java.util.Objects; | ||
import java.util.UUID; | ||
|
||
@Entity | ||
public class Car { | ||
|
||
|
||
@Id | ||
private String id; | ||
|
||
@Column | ||
private String vin; | ||
@Column | ||
private String model; | ||
@Column | ||
private String make; | ||
@Column | ||
private String transmission; | ||
|
||
public String id() { | ||
return id; | ||
} | ||
|
||
public String vin() { | ||
return vin; | ||
} | ||
|
||
public String model() { | ||
return model; | ||
} | ||
|
||
public String make() { | ||
return make; | ||
} | ||
|
||
public String transmission() { | ||
return transmission; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
if (o == null || getClass() != o.getClass()) { | ||
return false; | ||
} | ||
Car car = (Car) o; | ||
return Objects.equals(id, car.id); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hashCode(id); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "Car{" + | ||
"id='" + id + '\'' + | ||
", vin='" + vin + '\'' + | ||
", model='" + model + '\'' + | ||
", make='" + make + '\'' + | ||
", transmission='" + transmission + '\'' + | ||
'}'; | ||
} | ||
|
||
public static Car of(Faker faker){ | ||
Vehicle vehicle = faker.vehicle(); | ||
Car car = new Car(); | ||
car.id = UUID.randomUUID().toString(); | ||
car.vin = vehicle.vin(); | ||
car.model = vehicle.model(); | ||
car.make = vehicle.make(); | ||
car.transmission = vehicle.transmission(); | ||
return car; | ||
} | ||
} |
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,20 @@ | ||
package org.jnosql.demo.se; | ||
|
||
import jakarta.data.page.Page; | ||
import jakarta.data.page.Pageable; | ||
import jakarta.data.repository.DataRepository; | ||
import jakarta.data.repository.Delete; | ||
import jakarta.data.repository.Repository; | ||
import jakarta.data.repository.Save; | ||
|
||
@Repository | ||
public interface Garage extends DataRepository<Car, String>{ | ||
|
||
@Save | ||
Car parking(Car car); | ||
|
||
@Delete | ||
void departure(Car car); | ||
|
||
Page<Car> findByTransmission(String transmission, Pageable page); | ||
} |