Получение:
org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: ( near line 1, column 115
для этого запроса в Java-проекте
@Query("SELECT new com.sahaara.reports.entity.IncomeVsActualExpense(A.lineItems,A.donorId,A.donationAmount,B.amount) "
+ "FROM ( SELECT new com.sahaara.reports.entity.Donor(donorId,donorName,donationAmount,purposeOfDonation,lineItems) from Donor where purposeOfDonation= :projectName group by lineItems,donorId)" +
" A JOIN (SELECT new com.sahaara.reports.entity.ActualExpense(project,donorId,amount,lineItems) FROM ActualExpense where project = :projectName group by lineItems,donorId)B " +
" on B.lineItems= A.lineItems and A.donorId=B.donorId")
Соответствующий запрос MySQl -> Это прекрасно работает
select A.c_lineItems as LineItems, A.c_donorId as DonorId, A.c_amount as Income, B.c_TotalAmount as Expense
from(
SELECT c_lineItems,c_donorId,c_amount FROM abc.app_fd_rajeevexpensetable where c_project="xyz" group by c_lineItems,c_donorId
) A
join (
SELECT c_donor_id,c_DonorName,c_lineItems,c_TotalAmount FROM abc.app_fd_rajeevtable where c_DonorPurposeOfDonation="xyz" group by c_lineItems,c_donor_id
) B on B.c_lineItems= A.c_lineItems and A.c_donorId=B.c_donor_id
У меня есть
@Repository
public interface ActualExpenseRepository extends JpaRepository<ActualExpense,String>{
@Repository
public interface ActualExpenseRepository extends JpaRepository<ActualExpense,String>{
С классом DTO IncomeVsActualExpense
И я сохранил свой запрос в ActualExpenseRepository