SQL Error: 17006, SQLState: null Invalid column name in Hibernate

Recently I've got the following error during SQL named query execution:

SQL Error: 17006, SQLState: null Invalid column name

In order to track the problem down I enabled SQL logging and collected SQL query issued, then run it under SQL monitor and … it was working without error! I was surprised.

In order to debug what's going on I enabled detailed logging in Hibernate. What was happened then?

[INFO] could not read column value from result set: entityKey215_0_; Invalid column name

This message showed me that the problem was not related to generated SQL query but to column names expected by Hibernate. Generated recordset didn't has entityKey215_0_ column. I added:

entityKey AS {list.entityKey}

to named SQL query and error dissapeared.

This error is not-very-obvious kind of error because Oracle hides column / table names in error messages returned. Why? I don't get this cryptic error messages idea. In order to track an error under Oracle I had to enable verbose logging (error message standalone din't give anything useful). Much simpler database MySQL has better error reporting than "fat" Oracle.

This entry was posted in en and tagged , , . Bookmark the permalink.

5 Responses to SQL Error: 17006, SQLState: null Invalid column name in Hibernate

  1. Anonymous says:

    Could you talk deeper into the problem, such as the cause of it please? we don't quite understand the solution you provided there, is "list" the table name?

    Thanks 🙂

  2. dariusz.cieslak says:

    "list" is an alias for object. {list.propertyName} will be translated by Hibernate to some mangled names in order to decode column values into object properties (an ORM job). The warning is visible when Hibernate fails to find value for some properties.

  3. Raghunath says:

    Hi Dariusz,

    Can you please provide me where should i keep that statement in the named query. I really feel bad myself as i am new to hibernate. Even i am facing the same kind of issue. I am using hibernate3.3.2.jar with Oracle 11g. Please publish the complete syntax of entityKey AS {list.entityKey} where should i add this line. In my case it is Ticket1_58_0 is an invalid column.


  4. Ricardo Mozart Lino says:

    Excellent, resolved my problem.

    Congratulations for sharing that.


  5. Manjesh says:

    Hi Ricardo ,

    I ma facing the same issue. How did you resolve it?


Leave a Reply

Your email address will not be published.