You have a table in a database based on the following class (the table's name and fields are the same):
Java
@Entity
public class Car {
@Id
@GeneratedValue
private long id;
private String model;
private int year;
// constructor, getters, setters
}
Kotlin
@Entity
class Car (
@Id
@GeneratedValue
var id: Long = 0,
var model: String = "",
var year: Int = 0
)
You want to find the 30 oldest cars to try and sell them as soon as possible. Which methods can help you find them?