Andrzej Sawoniewicz
07/26/2018, 11:14 AM// Cross table entity class
@Entity(
primaryKeys = ["boundId", "flightId"],
indices = [
(Index("boundId")), (Index("flightId"))
],
foreignKeys = [
(ForeignKey(entity = Bound::class, parentColumns = arrayOf("id"), childColumns = arrayOf("boundId"), onDelete = ForeignKey.CASCADE)),
(ForeignKey(entity = Flight::class, parentColumns = arrayOf("id"), childColumns = arrayOf("flightId")))
]
)
data class FlightBooking(val boundId: Long, val flightId: Long)
// Pojo class
data class FlightBookingWithFlight(
@Embedded
val flightBooking: FlightBooking,
@Relation(parentColumn = "flightId", entityColumn = "id", entity = Flight::class)
val flightWithAirlinesAndAirportsSet: Set<FlightWithAirlinesAndAirports>
)
I got the error:
FlightBookingWithFlight.java6 error: Entities and Pojos must have a usable public constructor. You can have an empty constructor or a constructor whose parameters match the fields (by name and type).
public final class FlightBookingWithFlight {