I have a entity class
public class Hex {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY, generator = "native")
@Column(name = "hex_id")
private Long hexId;
@Column(name = "class")
String vehicleClass;
@Column(name = "manufacturer")
String manufacturer;
}
I need distinct manufacturer on basis of Vehicleclass, I am using below function
List<Hex> findManufacturerDistinctByVehicleClass(String classId);
But this return Distinct Hex objects on the basis of vehicle ID ,I observed the query in console and it was fetching results based on distinct primary key and applying a where clause on class
select
distinct hex0_.hex_id as hex_id1_1_,
hex0_.Manufacturer as manufact2_1_,
hex0_.class as class3_1_
from
hex hex0_
where
hex0_.class=?
I can do it by using @Query but I am looking for a derived query solution and if cannot be done then why