Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I need to execute select ST_AsText(column_name) from table using hibernate createSQlQuery().

When i executed that query, it shows that the column name is not found in the result set.
But when i execute the same query in my PGAdmin browser, the query works.

Query query = session.createSQLQuery("select ST_AsText(END2536) from country   where        object='something'");
((SQLQuery) query).addScalar(column, Hibernate.STRING);
String geomValue = (String) query.uniqueResult();
query.setCacheable(true);
query.setCacheRegion("query.CommonManagement");

Error Msg:

16:56:27,076 INFO  [org.hibernate.type.StringType] (http--172.20.211.235-8080-1) could not read column value from result set: END2536; The column name END2536 was not found in this ResultSet.
16:56:27,077 WARN  [org.hibernate.util.JDBCExceptionReporter] (http--172.20.211.235-8080-1) SQL Error: 0, SQLState: 42703
16:56:27,077 ERROR [org.hibernate.util.JDBCExceptionReporter] (http--172.20.211.235-8080-1) The column name END2536 was not found in this ResultSet.
16:56:27,080 ERROR [stderr] (http--172.20.211.235-8080-1) org.hibernate.exception.SQLGrammarException: could not execute query

What am i missing here?

share|improve this question
1  
Could you add source you use, and the error msg? – Ondra Žižka 22 hours ago
Query query = session.createSQLQuery("select ST_AsText(END2536) from country where object='something'; ((SQLQuery) query).addScalar(column,Hibernate.STRING); String geomValue = (String) query.uniqueResult(); query.setCacheable(true); query.setCacheRegion("query.CommonManagement"); – Rinny 20 hours ago
Error Msg 16:56:27,076 INFO [org.hibernate.type.StringType] (http--172.20.211.235-8080-1) could not read column value from result set: END2536; The column name END2536 was not found in this ResultSet. 16:56:27,077 WARN [org.hibernate.util.JDBCExceptionReporter] (http--172.20.211.235-8080-1) SQL Error: 0, SQLState: 42703 16:56:27,077 ERROR [org.hibernate.util.JDBCExceptionReporter] (http--172.20.211.235-8080-1) The column name END2536 was not found in this ResultSet. 16:56:27,080 ERROR [stderr] (http--172.20.211.235-8080-1) org.hibernate.exception.SQLGrammarException: could not execute query – Rinny 20 hours ago
Please add it to the question, like I did, next time :) And properly format. You'll have higher chance to get an answer. – Ondra Žižka 18 hours ago
thanks. :) do u have any answer? – Rinny 3 hours ago

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.