-->
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: Invalid column name
PostPosted: Tue Dec 12, 2006 8:35 pm 
Newbie

Joined: Tue Dec 12, 2006 8:27 pm
Posts: 1
I was trying to use a native query and got the following exception.

Hibernate: SELECT DP.DOCUMENT_PACKAGE_ID, DP.DOCUMENT_SIGNED_DATE, DP.DOCUMENT_SIGNED_IND,
DC.DOCUMENT_PACKAGE_ID, DC.DOB, DC.FIRST_NAME, DC.GENDER, DC.LAST_NAME, DC.MIDDLE_NAME, DC.SSN
FROM DOCUMENT_PACKAGE DP
LEFT OUTER JOIN DOCUMENT_CLIENT DC ON (DP.DOCUMENT_PACKAGE_ID = DC.DOCUMENT_PACKAGE_ID)
WHERE DP.DOCUMENT_PACKAGE_ID = ?
WARN [org.hibernate.util.JDBCExceptionReporter] - <SQL Error: 17006, SQLState: null>
ERROR [org.hibernate.util.JDBCExceptionReporter] - <Invalid column name>
ERROR [sample.maxie.dao.DocumentPackageDAO] - <get failed>
org.hibernate.exception.SQLGrammarException: could not execute query
at org.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:70)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.doList(Loader.java:1596)
at org.hibernate.loader.Loader.list(Loader.java:1577)
at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:112)
at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1414)
at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:153)
at sample.maxie.dao.DocumentPackageDAO.getDocumentPackageWithClient(DocumentPackageDAO.java:94)
at sample.maxie.utils.Runner.documentPackageWithClient(Runner.java:71)
at sample.maxie.utils.Runner.main(Runner.java:88)
Caused by: java.sql.SQLException: Invalid column name
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:208)
at oracle.jdbc.driver.OracleStatement.getColumnIndex(OracleStatement.java:3287)
at oracle.jdbc.driver.OracleResultSetImpl.findColumn(OracleResultSetImpl.java:1914)
at oracle.jdbc.driver.OracleResultSet.getLong(OracleResultSet.java:1575)
at org.hibernate.type.LongType.get(LongType.java:26)
at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:77)
at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:68)
at org.hibernate.loader.Loader.getKeyFromResultSet(Loader.java:759)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:292)
at org.hibernate.loader.Loader.doQuery(Loader.java:412)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:218)
at org.hibernate.loader.Loader.doList(Loader.java:1593)
... 7 more

The named query that I used for this is

Code:
    <sql-query name="documentPackageWithClient">
        <return alias="DP" class="sample.maxie.pojos.DocumentPackage"/>
        <return alias="DC" class="sample.maxie.pojos.DocumentClient"/>
        <![CDATA[SELECT {DP}.DOCUMENT_PACKAGE_ID, {DP}.DOCUMENT_SIGNED_DATE, {DP}.DOCUMENT_SIGNED_IND,
                        {DC}.DOCUMENT_PACKAGE_ID, {DC}.DOB, {DC}.FIRST_NAME, {DC}.GENDER, {DC}.LAST_NAME, {DC}.MIDDLE_NAME, {DC}.SSN
                 FROM DOCUMENT_PACKAGE {DP}
                 LEFT OUTER JOIN DOCUMENT_CLIENT {DC} ON ({DP}.DOCUMENT_PACKAGE_ID = {DC}.DOCUMENT_PACKAGE_ID)
                 WHERE {DP}.DOCUMENT_PACKAGE_ID = :paramDocumentPackageId]]>
    </sql-query>


and the Java code is


Code:
    public DocumentPackage getDocumentPackageWithClient(java.lang.Long id)
    {
        DocumentPackage retval = null;
        try
        {
            Query query = getSession().getNamedQuery("documentPackageWithClient");
            query.setParameter("paramDocumentPackageId", id);
            List buffer = query.list();
            retval      = ((buffer != null) && (buffer.size() > 0)) ? (DocumentPackage) buffer.get(0) : null;
        }
        catch (RuntimeException re)
        {
            log.error("get failed", re);
            throw re;
        }
       
        return(retval);
    }


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 13, 2006 12:12 am 
Newbie

Joined: Thu Aug 10, 2006 12:25 am
Posts: 13
Have you tried to turn on SQL debugging you can see what SQL statement was sent to the DB. Then try and run the statement by hand.


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.