javaoracle-databasenetbeans-7ejbql

Wrong Oracle SQL script generation from EJB QL


I have this query

SELECT acc.Id 
  FROM Auth as auth, AccId as acc 
 WHERE acc.ownId.Id = auth.Id 
   AND acc.disabled = 0

Which appears to have been generated correctly:

org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLSyntaxErrorException: ORA-00904: "T1"."A_ID"."T1"."A_ID": invalid identifier

Obviously acc.ownId.Id was not generated properly.

How could this have happened?


Solution

  • Please show your table definition, it makes it easier. Provide your table information and we can take a look at the create table clause.

    acc.ownId.Id is wrong identifier for a column, if you dont put " " around it!

    Check the correct column.

    maybe

    acc.ownId only? or acc."ownId.Id" ?

    IF your column name was created as:

    Create table AccId (
    ...
    "ownId.Id" int,
    ...
    );
    

    It works, but I would not recommend this kind of naming.

    Then of course you will need to wrapp it with " " if you use it in your query.

    i.e.

    WHERE acc."ownId.Id" = auth.Id