I want to search in spring data jpa by bedType. But, bedType is not string. Not String bedType but BedType bedType(Object). Here is my repository
@Query("select a,b.bedType,b.roomCategory from RoomDetail a left outer join RoomMaster b on a.roomId = b.id where lower(b.bedType) like %:bedType%")
<Page>RoomDetail findByBedType(
@Param("bedType") BedType bedType,
Pageable paging);
FindRoomStatus.Java
public class FindRoomStatus {
private BedType bedType;
public BedType getBedType() {
return bedType;
}
public void setBedType(BedType bedType) {
this.bedType = bedType;
}
In my controller, I have got error
String cannot be a converted to BedType
data = roomDetailRepository.findByBedType(findRoomStatus.getBedType().toString(), paging);
Here is BedType.Java
public class BedType implements Serializable{
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY, generator = "bed_type_seq")
@SequenceGenerator(name = "bed_type_seq", sequenceName = "bed_type_id_bed_type_seq", allocationSize = 1, initialValue = 1)
private int id;
@Column(name = "bed_type_name", length = 20)
private String bedTypeName;
@JsonIgnore
@Column(name = "status", length = 10)
private String status;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getBedTypeName() {
return bedTypeName;
}
public void setBedTypeName(String bedTypeName) {
this.bedTypeName = bedTypeName;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
List Room Status, in this list, i want to find by BedType
{
"id": 105,
"roomId": 43,
"floor": "1",
"roomNumber": "001",
"description": "Normal",
"status": "Vacant Clean"
},
{
"id": 11,
"bedTypeName": "King size"
},
{
"id": 39,
"categoryName": "President Suite"
}