'Persisting in Quarkus with Kotlin
I'm working with Quarkus in kotlin language and PostgreSQL. The code is REACTIVE with all correct required dependencies, Im having hardtime in Persisting the entity Received through POST call, I'm new to reactive programming and following repository method
This is my model Class
@Entity
@Cacheable
class AeroPlane
{
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
var planeId:Long = 0
lateinit var model:String
var numberOfSeats: Int = 0
var numberOfPassengers: Int = 0
var numberOfCabinCrew: Int = 0
var emergency:Boolean = false
}
This is my Repository Class
@ApplicationScoped
class AeroplaneService: PanacheRepository<AeroPlane>
{
}
This is my controller class
@Path("/aeroplane")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
class AeroplaneController
{
@Inject
lateinit var aeroplaneService: AeroplaneService
@POST
@Path("/saveAPlane")
@Transactional
fun saveAPlane(aeroPlane: AeroPlane): Uni<AeroPlane>? {
return aeroplaneService.persist(aeroPlane) //This is not working
}
@GET
@Path("/getAllPlane")
fun getAllPlane(): Uni<MutableList<AeroPlane>>? {
return aeroplaneService.listAll()
}
}
aeroplane is not persisting in kotlin, I have found how to persist in Java but there are not enough good resource for kotlin Java Solution
@POST
@Path("/saveAPlane")
public savePlane(Aeroplane aeroplane)
{
return Panache.withTransaction(aeroplane::persist)
.replaceWith(Response.ok(aeroplane)
.status(CREATED)::build);
}
Help please....
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
