-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: createSQLQuery results in "invalid identifier"
PostPosted: Fri Aug 18, 2006 10:50 am 
Beginner
Beginner

Joined: Thu Dec 09, 2004 3:19 pm
Posts: 34
Hibernate version:
2.1

Long story short, I will need to run straight SQL and so I'm trying to use createSQLQuery. I keep getting invalid identifier. I've simplified the query to what looks like about the most basic form and I still get the error.

Near as I can tell, this looks exactly like the chapter 13 example in the Hibernate Reference Documentation 2.1.6.

What am I doing wrong?

Collection f = hibSvc.getSession().createSQLQuery( "select {se.*} from SYSTEM_EVENT {se}", "se", SystemEventActivity.class ).list();

07:44:09,592 DEBUG SQL:226 - select se.ACTIVITY_ID as ACTIVITY1_0_, se.MESSAGE as MESSAGE2_0_, se_1_.VMID as VMID0_0_, se_1_.CREATED_AT as CREATED_AT0_0_, se_1_.LAST_UPDATE as LAST_UPD4_0_0_, se_1_.STATUS as STATUS0_0_, se_1_.RESULT as RESULT0_0_ from SYSTEM_EVENT se
07:44:09,873 WARN JDBCExceptionReporter:38 - SQL Error: 904, SQLState: 42000
07:44:09,873 ERROR JDBCExceptionReporter:46 - ORA-00904: "SE_1_"."RESULT": invalid identifier

07:44:09,889 WARN JDBCExceptionReporter:38 - SQL Error: 904, SQLState: 42000
07:44:09,889 ERROR JDBCExceptionReporter:46 - ORA-00904: "SE_1_"."RESULT": invalid identifier

07:44:09,889 ERROR JDBCExceptionReporter:38 - SQLException occurred
java.sql.SQLException: ORA-00904: "SE_1_"."RESULT": invalid identifier

at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:743)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:216)
at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:799)
at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1039)
at oracle.jdbc.driver.T4CPreparedStatement.executeMaybeDescribe(T4CPreparedStatement.java:839)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1132)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3285)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3329)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeQuery(NewProxyPreparedStatement.java:76)
at net.sf.hibernate.impl.BatcherImpl.getResultSet(BatcherImpl.java:87)
at net.sf.hibernate.loader.Loader.getResultSet(Loader.java:875)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:269)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
at net.sf.hibernate.loader.Loader.doList(Loader.java:1033)
at net.sf.hibernate.loader.Loader.list(Loader.java:1024)
at net.sf.hibernate.loader.SQLLoader.list(SQLLoader.java:92)
at net.sf.hibernate.impl.SessionImpl.findBySQL(SessionImpl.java:3806)
at net.sf.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:52)
at com.HQLQueryRunner.main(HQLQueryRunner.java:48)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:78)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 18, 2006 12:34 pm 
Senior
Senior

Joined: Wed Aug 17, 2005 12:56 pm
Posts: 136
Location: Erie, PA (USA)
Can we see the mapping, POJO and structure of table? It looks like a mismatch between table and mapping. I've always avoided the usage of {alias.*} -- it may work, I just tend to match each column in result to a specific property:
Code:
SELECT se.col1 AS {alias.col1val}, se.col2 AS {alias.col2val} FROM SYSTEM_EVENT se


Also notice that I don't use the {...} notation for the table alias.

Curtis ...

_________________
---- Don't forget to rate! ----


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.