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 fetch all the car objects of a certain model from the database. Which method do you define in the repository?
Java
1) List<Car> findByModel(String model)
2) Optional<Car> findByModel(String model)
3) List<Car> searchByModel(String model)
4) Optional<Car> searchByModel(String model)
Kotlin
1) findByModel(model: String): List<Car>
2) findByModel(model: String): Car?
3) searchByModel(model: String): List<Car>
4) searchByModel(model: String): Car?