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
var id: Long = 0,
var model: String = "",
var type: String = "",
var price: Int = 0
)
How do you get the instance of Sort that will help you fetch the data from the database sorted by price: from cheaper to more expensive? Choose all possible options.
Java
-
Sort productSort = Sort.by("price"); -
Sort productSort = Sort.by("price").ascending(); -
Sort productSort = Sort.by(Sort.Direction.ASC, "price"); -
Sort productSort = Sort.by("price", Sort.Direction.ASC);
Kotlin
-
val productSort: Sort = Sort.by("price") -
val productSort: Sort = Sort.by(Sort.Order.asc("price")) -
val productSort: Sort = Sort.by(Sort.Direction.ASC, "price") -
val productSort: Sort = Sort.by(Sort.Order.asc("price"))