A dream car

Report a typo

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
)

Your client wants a car model of a certain year of production. Which methods can you use to fetch all the variants from the database?

Java

1) List<Car> findByModelAndYear(String model, int year)

2) List<Car> findByYearAndModel(int year, String model)

3) List<Car> findByYearAndModel(String model, int year)

4) List<Car> findByYearOrModel(int year, String model)

5) List<Car> findByModelOrYear(String model, int year)

Kotlin

1) findByModelAndYear(model: String, year: Int): List<Car>

2) findByYearAndModel(year: Int, model: String): List<Car>

3) findByYearAndModel(model: String, year: Int): List<Car>

4) findByYearOrModel(year: Int, model: String): List<Car>

5) findByModelOrYear(model: String, year: Int): List<Car>

Select one or more options from the list
___

Create a free account to access the full topic