Skip to content

Commit

Permalink
Mise à jour pour présentation nantaise 2024 : correction exercice 02.02
Browse files Browse the repository at this point in the history
  • Loading branch information
flodesPhenix committed Sep 21, 2024
1 parent 05b38da commit 0b2a890
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import java.io.Serializable;

@Entity(name = "Vehicle")
@Cacheable
public class Vehicle implements Serializable {

@Id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,22 @@ public Uni<Vehicle> createVehicle(Vehicle vehicle) {
return persist(vehicle);
}


public Uni<Vehicle> findVehicleById(Long id) {
return findById(id);
}


public Uni<Boolean> deleteVehicleById(Long id) {
return deleteById(id);
}


public void updateVehicle(Long id,Vehicle vehicle) {
Vehicle toUpdate = findById(id).await().indefinitely();
toUpdate.name = vehicle.name;
toUpdate.speed = vehicle.speed;
toUpdate.acceleration = vehicle.acceleration;
public Uni<Vehicle> updateVehicle(Long id, Vehicle vehicle) {
return findById(id)
.onItem().ifNotNull().transformToUni(toUpdate -> {
toUpdate.name = vehicle.name;
toUpdate.speed = vehicle.speed;
toUpdate.acceleration = vehicle.acceleration;
return persist(toUpdate);
});
}
}

0 comments on commit 0b2a890

Please sign in to comment.