I am working on a Spring Hibernate application which uses Oracle 11G database. I have a table from which I want to select three columns and display it in a jsp page. Now, one of the columns has data in the format- abc+def+xyz. I have to display "abc", "def" and "xyz" in 3 different columns in my jsp page. For that, I have written the following query in my DAO:
SQLQuery query=sessionFactory.getCurrentSession().createSQLQuery("SELECT TABLE_ID, REGEXP_SUBSTR(TABLE_UID, '[^+]+', 1, 3) AS FIRST_COLUMN, REGEXP_SUBSTR(TABLE_UID, '[^+]+', 1, 2) AS SECOND_COLUMN, REGEXP_SUBSTR(TABLE_UID, '[^+]+', 1, 1) AS THIRD_COLUMN, USERID FROM TABLE_TABLE1 WHERE USERID='abhi'");
The names of my columns are- TABLE_ID, TABLE_UID, USERID and the name of my table is- TABLE_TABLE1. When I run this, I'm getting-
org.hibernate.exception.GenericJDBCException: could not execute query] with root cause
java.sql.SQLException: Invalid column name.
But the same query when executed in SQL, is giving expected output. I don't understand why I'm getting this discrepancy