we are using UNION ALL in AST Translator in hibernate it is showing errorCode:
criteria[i].getValue(aliasType.get(fieldAlias).toString());
paymentSubQuery.append(" Invoice.id in (( Select InvoiceExpense.invoiceId ");
paymentSubQuery.append(" from InvoiceExpenseVO as InvoiceExpense, " );
paymentSubQuery.append(" ExpensePaymentAllocVO as ExpensePaymentAlloc ");
paymentSubQuery.append(" where InvoiceExpense.lineNumber = ExpensePaymentAlloc.charge.lineNumber " );
paymentSubQuery.append(" and ExpensePaymentAlloc.payment.id " + fieldValue + ")");
paymentSubQuery.append(" UNION ALL ( Select InvoiceFee.invoiceId" );
paymentSubQuery.append(" from InvoiceFeeVO as InvoiceFee, " );
paymentSubQuery.append(" FeePaymentAllocVO as FeePaymentAlloc ");
paymentSubQuery.append(" where InvoiceFee.lineNumber = FeePaymentAlloc.charge.lineNumber " );
paymentSubQuery.append(" and FeePaymentAlloc.payment.id " + fieldValue + ")");
paymentSubQuery.append(" UNION ALL ( Select InvoiceExpense.invoiceId " );
paymentSubQuery.append(" from InvoiceExpenseVO as InvoiceExpense, " );
paymentSubQuery.append(" PaymentReserveVO as PaymentReserve ");
paymentSubQuery.append(" where InvoiceExpense.lineNumber = PaymentReserve.expenseLineNumber " );
paymentSubQuery.append(" and PaymentReserve.paymentId " + fieldValue + ")");
paymentSubQuery.append(" UNION ALL ( Select InvoiceTrading.outgoingInvoice.id ");
paymentSubQuery.append(" from InvoiceTradingVO as InvoiceTrading, " );
paymentSubQuery.append(" TradingPaymentAllocVO as TradingPaymentAlloc ");
paymentSubQuery.append(" where InvoiceTrading.charge.lineNumber = TradingPaymentAlloc.charge.lineNumber " );
paymentSubQuery.append(" and TradingPaymentAlloc.payment.id " + fieldValue + ")");
paymentSubQuery.append(" )" );
invoiceOuterWhereClause.add(paymentSubQuery.toString());
Error:
org.hibernate.hql.ast.QuerySyntaxException: expecting CLOSE, found 'UNION' near line 1, column 481 [Select Invoice from com.bofa.crme.dac.persistence.valueobject.InvoiceVO as Invoice where Invoice.id in (( Select InvoiceExpense.invoiceId from com.bofa.crme.dac.persistence.valueobject.InvoiceExpenseVO as InvoiceExpense, com.bofa.crme.dac.persistence.valueobject.ExpensePaymentAllocVO as ExpensePaymentAlloc where InvoiceExpense.lineNumber = ExpensePaymentAlloc.charge.lineNumber and ExpensePaymentAlloc.payment.id = 1538) UNION ALL ( Select InvoiceFee.invoiceId from com.bofa.crme.dac.persistence.valueobject.InvoiceFeeVO as InvoiceFee, com.bofa.crme.dac.persistence.valueobject.FeePaymentAllocVO as FeePaymentAlloc where InvoiceFee.lineNumber = FeePaymentAlloc.charge.lineNumber and FeePaymentAlloc.payment.id = 1538) UNION ALL ( Select InvoiceExpense.invoiceId from com.bofa.crme.dac.persistence.valueobject.InvoiceExpenseVO as InvoiceExpense, com.bofa.crme.dac.persistence.valueobject.PaymentReserveVO as PaymentReserve where InvoiceExpense.lineNumber = PaymentReserve.expenseLineNumber and PaymentReserve.paymentId = 1538) UNION ALL ( Select InvoiceTrading.outgoingInvoice.id from com.bofa.crme.dac.persistence.valueobject.InvoiceTradingVO as InvoiceTrading, com.bofa.crme.dac.persistence.valueobject.TradingPaymentAllocVO as TradingPaymentAlloc where InvoiceTrading.charge.lineNumber = TradingPaymentAlloc.charge.lineNumber and TradingPaymentAlloc.payment.id = 1538) )]
I think AST doesnot support UNION ALL in hibernate, so can any one tell me is there any alternate solution that we can use apart from UNION ALL.Thanks in Advance!!!