Вы ссылаетесь на type_id
из списка, который здесь не разрешен, потому что выражение запроса ссылается на type_id
на список, а не на сам объект. Так что замените только это LEFT JOIN e.typesOfEvents.type_id t
на LEFT JOIN e.typesOfEvents t
, и все будет нормально. И он будет ссылаться на переменную t
на элемент из списка (Relation).
@Query("SELECT new com.test.responseDTO.TestDTO(e.id, e.multipleDays, e.typesOfEvents, e.startDate, e.startTime, e.endDate, e.endTime, e.eventName, e.subTitle, e.location, c.name, e.fee, e.paid, e.eventImg, p.event_passport_option_id, e.passportTickets, e.remainingTickets, e.passport, e.promoCode, e.expectedAttendance, e.myFavourite, s.status, e.featured)" +
" from Events e LEFT JOIN e.typesOfEvents t /*this fixed*/ JOIN e.city c JOIN e.eventPassportOptions p JOIN e.eventStatus s WHERE e.startDate BETWEEN :startDate AND :endDate AND e.endDate BETWEEN :startDate AND :endDate ORDER BY e.startDate, e.id ASC")
List<TestDTO> findAllListOfEventsWithoutEventTypeIdWithOnlyTwoDateTest1(String startDate, String endDate);
My Query с изменениями в TestDTO
@Query("SELECT new com.techavidus.networkingPhoniex.responseDTO.TestDTO(e.id, e.multipleDays, t, e.startDate, e.startTime, e.endDate, e.endTime, e.eventName, e.subTitle, e.location, c.name, e.fee, e.paid, e.eventImg, p.event_passport_option_id, e.passportTickets, e.remainingTickets, e.passport, e.promoCode, e.expectedAttendance, e.myFavourite, s.status, e.featured)" +
" from Events e LEFT JOIN e.typesOfEvents t JOIN e.city c JOIN e.eventPassportOptions p JOIN e.eventStatus s WHERE e.startDate BETWEEN :startDate AND :endDate AND e.endDate BETWEEN :startDate AND :endDate ORDER BY e.startDate, e.id ASC")
List<TestDTO> findAllListOfEventsWithoutEventTypeIdWithOnlyTwoDateTest1(String startDate, String endDate);
вывод:
{
"success": true,
"message": "Record's find successfully.",
"data": [
{
"date": "2020/05/28",
"count": 2,
"events": [
{
"id": 1,
"multipleDays": true,
"eventType": {
"type_id": 1,
"type": "Musician1",
"paid_listing": false,
"color": "Black",
"_enabled": true
},
"startDate": "2020/05/28",
"startTime": "10:12:15",
"endDate": "2020/05/30",
"endTime": "20:18:25",
"eventName": "Test",
"subTitle": "Testing demo",
"location": "string",
"city": "Bhuj",
"fee": 49,
"paid": false,
"eventImg": "Imgage url",
"passportOption": 1,
"passportTickets": 0,
"remainingTickets": 0,
"passport": false,
"promoCode": "TEST123",
"expectedAttendance": "1500",
"myFavourite": false,
"eventStatus": "Pending Approval",
"featured": false
},
{
"id": 1,
"multipleDays": true,
"eventType": {
"type_id": 2,
"type": "Personal Growth",
"paid_listing": true,
"color": "Black",
"_enabled": true
},
"startDate": "2020/05/28",
"startTime": "10:12:15",
"endDate": "2020/05/30",
"endTime": "20:18:25",
"eventName": "Test",
"subTitle": "Testing demo",
"location": "string",
"city": "Bhuj",
"fee": 49,
"paid": false,
"eventImg": "Imgage url",
"passportOption": 1,
"passportTickets": 0,
"remainingTickets": 0,
"passport": false,
"promoCode": "TEST123",
"expectedAttendance": "1500",
"myFavourite": false,
"eventStatus": "Pending Approval",
"featured": false
}
]
}
]
}