File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes Hibernate: invalid column name! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate: invalid column name!" Watch "Hibernate: invalid column name!" New topic
Author

Hibernate: invalid column name!

Payam Fard
Ranch Hand

Joined: Jan 31, 2003
Posts: 73
Hi all,

I am getting invalid column exception when trying to query data. Here is my mapping file:



MATRIX_CATEGORY table has the following two fields:

CATEGORY_ID: NUMBER
CATEGORY_DESC: VARCHAR2(35)

Here is my test program:



Any help would be appreciated.

Here is the exception I am getting:

Ok. Here is the stack trace if it might help:

[java] 16:30:38,843 WARN Configurator:123 - No configuration found. Config
uring ehcache from ehcache-failsafe.xml found in the classpath: jar:file:/C:/dev
/Hibernate-testing/lib/ehcache-0.7.jar!/ehcache-failsafe.xml
[java] 16:30:38,843 WARN Plugin:95 - Could not find configuration for net.
sf.hibernate.cache.UpdateTimestampsCache. Configuring using the defaultCache set
tings.
[java] 16:30:38,859 WARN Plugin:95 - Could not find configuration for net.
sf.hibernate.cache.QueryCache. Configuring using the defaultCache settings.
[java] 16:30:38,953 WARN JDBCExceptionReporter:38 - SQL Error: 904, SQLSta
te: 42000
[java] 16:30:38,953 ERROR JDBCExceptionReporter:46 - ORA-00904: invalid col
umn name

[java] 16:30:38,953 WARN JDBCExceptionReporter:38 - SQL Error: 904, SQLSta
te: 42000
[java] 16:30:38,953 ERROR JDBCExceptionReporter:46 - ORA-00904: invalid col
umn name

[java] 16:30:38,968 ERROR JDBCExceptionReporter:38 - Could not execute quer
y
[java] java.sql.SQLException: ORA-00904: invalid column name

[java] at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:1
68)
[java] at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:208)
[java] at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:543)
[java] at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1405)

[java] at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteDescribe(TTC7Protoc
ol.java:643)
[java] at oracle.jdbc.driver.OracleStatement.doExecuteQuery(OracleState
ment.java:1674)
[java] at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(Oracl
eStatement.java:1870)
[java] at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(Orac
lePreparedStatement.java:363)
[java] at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(Oracl
ePreparedStatement.java:314)
[java] at net.sf.hibernate.impl.BatcherImpl.getResultSet(BatcherImpl.ja
va:87)
[java] at net.sf.hibernate.loader.Loader.getResultSet(Loader.java:800)
[java] at net.sf.hibernate.loader.Loader.doQuery(Loader.java:189)
[java] at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCol
lections(Loader.java:133)
[java] at net.sf.hibernate.loader.Loader.doList(Loader.java:955)
[java] at net.sf.hibernate.loader.Loader.list(Loader.java:946)
[java] at net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.jav
a:846)
[java] at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1543)

[java] at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:39)
[java] at QueryTest.getCategoriesGreaterThan(QueryTest.java:27)
[java] at QueryTest.main(QueryTest.java:52)
[java] net.sf.hibernate.JDBCException: Could not execute query
[java] at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1546)

[java] at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:39)
[java] at QueryTest.getCategoriesGreaterThan(QueryTest.java:27)
[java] at QueryTest.main(QueryTest.java:52)
[java] Caused by: java.sql.SQLException: ORA-00904: invalid column name
[java] at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:1
68)
[java] at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:208)
[java] at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:543)
[java] at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1405)

[java] at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteDescribe(TTC7Protoc
ol.java:643)
[java] at oracle.jdbc.driver.OracleStatement.doExecuteQuery(OracleState
ment.java:1674)
[java] at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(Oracl
eStatement.java:1870)
[java] at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(Orac
lePreparedStatement.java:363)
[java] at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(Oracl
ePreparedStatement.java:314)
[java] at net.sf.hibernate.impl.BatcherImpl.getResultSet(BatcherImpl.ja
va:87)
[java] at net.sf.hibernate.loader.Loader.getResultSet(Loader.java:800)
[java] at net.sf.hibernate.loader.Loader.doQuery(Loader.java:189)
[java] at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCol
lections(Loader.java:133)
[java] at net.sf.hibernate.loader.Loader.doList(Loader.java:955)
[java] at net.sf.hibernate.loader.Loader.list(Loader.java:946)
[java] at net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.jav
a:846)
[java] at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1543)

[java] ... 3 more
[java] Exception in thread "main"
[java] Java Result: 1
[ July 22, 2004: Message edited by: Payam Fard ]
Payam Fard
Ranch Hand

Joined: Jan 31, 2003
Posts: 73
Well, I am not sure why this version does not work. But, I moved the query to the properties file and that fixed it.
Marcel Toma
Greenhorn

Joined: Aug 17, 2004
Posts: 1
How did you put the query in a property file?
did you put it in the hibernate.cfg.xml or a normal properties file?
Theodore Casser
Ranch Hand

Joined: Mar 14, 2001
Posts: 1902

Originally posted by Marcel Toma:
How did you put the query in a property file?
did you put it in the hibernate.cfg.xml or a normal properties file?


I think Payam might mean he stuck it in the hbm.xml file for the MatrixCategory class. Easy enough to stick a named query in there after the class tags, before the closing hibernate-mapping tag.

Just a guess.


Theodore Jonathan Casser
SCJP/SCSNI/SCBCD/SCWCD/SCDJWS/SCMAD/SCEA/MCTS/MCPD... and so many more letters than you can shake a stick at!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hibernate: invalid column name!
 
Similar Threads
Hibernate Problem
could not execute query
Executing stored procedures in hibernate
org.hibernate.exception.SQLGrammarException: could not execute query
Hibernate native sql problem