ORA-00904 When Executing Query On Entity Model Using Mixed Inheritance Strategy (Doc ID 1142543.1)

Last updated on MARCH 08, 2017

Applies to:

Oracle TopLink - Version 11.1.1.0.1 to 11.1.1.2.0 [Release Oracle11g]
Information in this document applies to any platform.
***Checked for relevance on 08-Mar-2013***

Symptoms

Entity Object Model

Employee (strategy="joined", discrimanator-column="EMP_TYPE")
CompanyEmployee extends Employee (strategy="SINGLE_TABLE)
ContractEmployee extends Employee (strategy="joined" <default>)
FullTimeEmployee extends CompanyEmployee (strategy="joined" <default>)
PartTimeEmployee extends CompanyEmployee (strategy="joined" <default>)

Problem Scenario

 

 

public static void main(String[] args) {
    EntityManagerFactory emf =
    Persistence.createEntityManagerFactory("BugMultipleTablesAndInheritance");

    EntityManager em = emf.createEntityManager();

    List<Employee> emps = (List<Employee>)
        em.createQuery("Select e FROM Employee e").getResultList();

    for (Employee emp : emps) {
        System.out.println(emp.toString());
    }

    List<ContractEmployee> contractEmps = (List<ContractEmployee>)
        em.createQuery("Select e FROM ContractEmployee e").getResultList();

    for (ContractEmployee emp : contractEmps) {
        System.out.println(emp.toString());
    }

    em.close();
    emf.close();
}


Observed Behavior

 

[EL Fine]: 2010-01-21 14:41:46.187--ServerSession(7756310)--Connection(20914447)--Thread(Thread[main,5,main])--SELECT t0.ID, t0.EMP_TYPE, t0.S_DATE, t0.NAME, t1.ID, t2.EMP_INFO_ID, t2.ID, t2.VACATION, t2.DEPT_ID, t2.SALARY, t2.PENSION FROM EMP t0, EMP_INFO t2, COMPANY_EMP t1 WHERE (((t2.ID = t0.ID) AND ((t1.ID = t2.EMP_INFO_ID) AND (t1.ID = t0.ID))) AND (t0.EMP_TYPE = ?))
bind => [2]
[EL Fine]: 2010-01-21 14:41:46.234--ServerSession(7756310)--Thread(Thread[main,5,main])--SELECT 1 FROM DUAL
[EL Warning]: 2010-01-21 14:41:46.25--UnitOfWork(25966201)--Thread(Thread[main,5,main])--Local Exception Stack:
Exception [EclipseLink-4002] (Eclipse Persistence Services - 1.2.0.v20091016-r5565): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: ORA-00904: "T2"."ID": invalid identifier

Error Code: 904
Call: SELECT t0.ID, t0.EMP_TYPE, t0.S_DATE, t0.NAME, t1.ID, t2.EMP_INFO_ID, t2.ID, t2.VACATION, t2.DEPT_ID, t2.SALARY, t2.PENSION FROM EMP t0, EMP_INFO t2, COMPANY_EMP t1 WHERE (((t2.ID = t0.ID) AND ((t1.ID = t2.EMP_INFO_ID) AND (t1.ID = t0.ID))) AND (t0.EMP_TYPE = ?))
bind => [2]
Query: ReadAllQuery(referenceClass=Employee sql="SELECT DISTINCT EMP_TYPE FROM EMP")
at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:333)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:685)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:528)
at org.eclipse.persistence.sessions.server.ServerSession.executeCall(ServerSession.java:529)
at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:205)
at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:191)
at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeSelectCall(DatasourceCallQueryMechanism.java:262)
at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.selectAllRows(DatasourceCallQueryMechanism.java:599)
at org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.selectAllRowsFromConcreteTable(ExpressionQueryMechanism.java:2509)
at org.eclipse.persistence.descriptors.InheritancePolicy.selectAllRowUsingDefaultMultipleTableSubclassRead(InheritancePolicy.java:1279)
at org.eclipse.persistence.descriptors.InheritancePolicy.selectAllRowUsingMultipleTableSubclassRead(InheritancePolicy.java:1313)
at org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.selectAllRows(ExpressionQueryMechanism.java:2474)
at org.eclipse.persistence.queries.ReadAllQuery.executeObjectLevelReadQuery(ReadAllQuery.java:455)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:997)
at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:670)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:958)
at org.eclipse.persistence.queries.ReadAllQuery.execute(ReadAllQuery.java:432)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:1021)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2858)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1225)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1207)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1181)
at org.eclipse.persistence.internal.jpa.EJBQueryImpl.executeReadQuery(EJBQueryImpl.java:420)
at org.eclipse.persistence.internal.jpa.EJBQueryImpl.getResultList(EJBQueryImpl.java:636)
at examples.tester.EntityTester.main(EntityTester.java:21)
Caused by: java.sql.SQLException: ORA-00904: "T2"."ID": invalid identifier

at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:743)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:216)
at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:799)
at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1038)
at oracle.jdbc.driver.T4CPreparedStatement.executeMaybeDescribe(T4CPreparedStatement.java:839)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1133)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3285)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3329)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeSelect(DatabaseAccessor.java:890)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:600)
... 23 more

Cause

Sign In with your My Oracle Support account

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

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms