Reputation: 17097
When I run this query : select emp.emp_name as "name" from emp order by name.
This runs fine from sqldeveloper. But through java, using a hibernate session, this gives an sql :invalid column error.
Why is this difference in behavior?
EDIT: The error says Invalid Column :NAME (in upper case) and not name. I will try this:
select emp.emp_name as "name" from emp order by "name"
Upvotes: 0
Views: 1636
Reputation: 73564
The name "name" is likely a reserved keyword. sql developer is being forgiving. Try
select emp.emp_name as [name] from emp order by [name]
or better yet, just don't use a reserved keyword, or even a possibly reserved keyword.
Even if this is not the issue (which it might not be depending on your platform/rdbms), you should avoid column names like "type", "DateTime", etc. for the sole purpose of code readability, reserved words conflicts aside.
Upvotes: 4