DB2 SQL Error: SQLCODE=-214, SQLSTATE=42822 using Hibernate

Solution Verified - Updated -

Issue

  • An HQL typed query uses DISTINCT and ORDER BY where the ORDER BY columns include a column that cannot be mapped to the HQL return type

    SELECT DISTINCT employee FROM Employee employee, Task task ... ORDER BY employee.name, task.id
    
  • The database driver raises an exception indicating the un-mapped column is illegal in the ORDER BY clause

    DB2 SQL Error: SQLCODE=-214, SQLSTATE=42822, SQLERRMC=id;ORDER BY;2, DRIVER=4.15.134
    

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP) 7
  • Hibernate 5

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content