My Oracle Support Banner

Ora-00918: Column Ambiguously Defined Error When Executing a Query (Doc ID 819962.1)

Last updated on MARCH 17, 2019

Applies to:

Oracle TopLink - Version 11.1.1.0.1 to 11.1.1.0.2 [Release Oracle11g]
Information in this document applies to any platform.

Symptoms

Entity Object Model

Query Definition

ReadAllQuery query = new ReadAllQuery();
query.setReferenceClass(Material.class);
ExpressionBuilder expression = query.getExpressionBuilder();
query.setSelectionCriteria(expression.get("id").equal("0"));

query.addJoinedAttribute(expression.getAllowingNull("Verpack"));
query.addJoinedAttribute(expression.getAllowingNull("Auft"));
query.addJoinedAttribute(expression.getAllowingNull("Auft").getAllowingNull("verar"));

List<Material > result = (List<Material >) session.executeQuery(query);

Generated SQL Statement

SELECT
  t1.ID,
  t1.TKSIDENT,
  t1.FK_Verpack_MATERIAL,
  t1.FK_Auft_MATERIAL,
  t0.ID,
  t2.ID,
  t2.CLASSTYPE,
  t3.ID,
  t3.FK_verar_VERAT,
  t4.ID
FROM
  Auft t3LEFT OUTER JOIN Kun t4 ON (t4.ID =t3.FK_verar_VERAT),
  MATERIAL t1 LEFT OUTER JOIN Verpack t0 ON (t0.ID=t1.FK_Verpack_MATERIAL)
    LEFT OUTER JOIN (ArbeitPLAN t2 JOIN Auft t3ON (t3.ID = t2.ID))
      ON (t2.ID = t1.FK_Auft_MATERIAL)
WHERE (t1.ID = ?)

Observed Behaviour

The following error occurs because "Auft t3" is used twice: 

Internal Exception: java.sql.SQLException: ORA-00918: column ambiguously defined

 

Changes

 

Cause

To view full details, sign in with your My Oracle Support account.

Don't have a My Oracle Support account? Click to get started!


In this Document
Symptoms
 Entity Object Model
 Query Definition
 Generated SQL Statement
 Observed Behaviour
Changes
Cause
Solution
References

My Oracle Support provides customers with access to over a million knowledge articles and a vibrant support community of peers and Oracle experts.