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 of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In
Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.