-1
SELECT
    c.CONSOL_INVOICE,
    cu.name,
    cu.CUST_CODE,
    c.bu_name, 
    cLang.name
FROM CONSL_INV c 
LEFT JOIN customers cu ON c.cust_code = cu.CUST_CODE,
    customers_lang cLang 
WHERE 
    upper(cLang.NAME) LIKE ?  
    AND upper(cLang.LANGUAGE_CD) = ? 
    AND c.CUST_CODE = cLang.CUST_CODE

This Query Executes Correctly In Oracle Sql Developer but it does not execute in hibernate.

It gives the following error:

"ORA-00918: column ambiguously defined"

I know it's because of multiple columns having same name, but I have done it correctly but still don't know why it's not executing in hibernate.

Andrea
  • 11,801
  • 17
  • 65
  • 72
user2218550
  • 147
  • 1
  • 2
  • 11

1 Answers1

0

As the others suggested use aliases:

select c.consol_invoice
      ,cu.name as name1
      ,cu.cust_code
      ,c.bu_name
      ,clang.name as name2
  from consl_inv c
  left join customers cu
    on c.cust_code = cu.cust_code, customers_lang clang
 where upper(clang.name) like ?
   and upper(clang.language_cd) = ?
   and c.cust_code = clang.cust_code

As you can see I've added aliases to the selected columns cu.name and clang.name so that the query result has two different columns.

Rene
  • 10,391
  • 5
  • 33
  • 46