Creating a custom method

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 Product {
    
    @Id
    @GeneratedValue
    private long id;
    private String model;
    private String type;
    private int price;

    // constructor, getters, setters
}
Kotlin
@Entity
data class Product(
    @Id
    @GeneratedValue
    val id: Long = 0,
    val model: String? = null,
    val type: String? = null,
    val price: Int = 0
)

You want to fetch the products of a certain model from the database and then page them. Which methods do you need to do it?

Java
  1. Page<Product> findAll(String model, Pageable pageable);
  2. Page<Product> findByModel(Pageable pageable, String model);
  3. Page<Product> findByModel(String model, Pageable pageable);
  4. List<Product> findByModel(String model, Pageable pageable);
  5. Page<Product> findByModel(Pageable pageable);
Kotlin
  1. fun findAll(model: String, pageable: Pageable): Page<Product>
  2. fun findByModel(pageable: Pageable, model: String): Page<Product>
  3. fun findByModel(model: String, pageable: Pageable): Page<Product>
  4. fun findByModel(model: String, pageable: Pageable): List<Product>
  5. fun findByModel(pageable: Pageable): Page<Product>
Select one or more options from the list
___

Create a free account to access the full topic