i am currently making a website using spring and i stumble upon this basic scenario that i don\'t have any idea on how to solve this specific code: Entity = Optional;
According to your error you are getting Optional from repository's findAll method and you are casting it to RoomEntity.
Optional
RoomEntity
Instead of RoomEntity roomEntity = roomRepository.findById(roomId); do this
RoomEntity roomEntity = roomRepository.findById(roomId);
Optional optinalEntity = roomRepository.findById(roomId); RoomEntity roomEntity = optionalEntity.get();