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.  [ 6 posts ] 
Author Message
 Post subject: Invalid column name
PostPosted: Wed Feb 04, 2009 4:27 am 
Newbie

Joined: Wed Feb 04, 2009 3:22 am
Posts: 3
Hi, I am getting exception while executing below code
Code:
Exception :
INFO: could not read column value from result set: I1_0_0_; Invalid column name
Feb 4, 2009 12:58:05 PM org.hibernate.util.JDBCExceptionReporter logExceptions
WARNING: SQL Error: 17006, SQLState: null
Feb 4, 2009 12:58:05 PM org.hibernate.util.JDBCExceptionReporter logExceptions
SEVERE: Invalid column name
Exception :org.hibernate.exception.GenericJDBCException: could not execute query



Code:
List<Catalog> var = session.getNamedQuery("catalogBySeason")
              .list();


Below is my mapping file
Code:
<hibernate-mapping>
  <class entity-name="testhibernateapp.Catalog" table="P_CATALOG">
    <composite-id>
      <key-property column="I_COMPANY" name="company" type="double"/>
      <key-property column="I_SEASON" name="season" type="double"/>
      <key-property column="I_CATALOG" name="catalog" type="double"/>
    </composite-id>
    <property column="S_CATALOGNAME" name="catalogname" type="string"/>
    <property column="I_CIRCULATION_ACT" name="circulationAct" type="double"/>
  </class>
  <sql-query name="catalogBySeason">
   <return class="testhibernateapp.Catalog" alias="c">
       <return-property name="company" column="I_COMPANY"></return-property>
   </return>
    SELECT p.I_COMPANY AS {c.company} FROM P_CATALOG p
  </sql-query>
</hibernate-mapping>



Top
 Profile  
 
 Post subject: Re: Invalid column name
PostPosted: Wed Feb 04, 2009 7:28 am 
Beginner
Beginner

Joined: Wed Jul 09, 2008 5:34 am
Posts: 41
Location: Brno, Czech Republic
What is the Hibernate version? What is the driver version? I tested your code here, on Oracle 10g, using driver version 10.0.2.2, and it worked fine :-)


Top
 Profile  
 
 Post subject: RE: Invalid column name
PostPosted: Thu Feb 05, 2009 2:03 am 
Newbie

Joined: Wed Feb 04, 2009 3:22 am
Posts: 3
Thanx for your input jpkrohling,

I am testing it in oracle 10g using hiernate 3, and driver version is 10.2.0.3.0.

Still I am facing the same problem..

Below is the detail error log.

Code:
Hibernate:
    SELECT
        p.I_COMPANY as I_COMPANY
    FROM
        P_CATALOG p
Feb 5, 2009 11:23:43 AM org.hibernate.type.NullableType nullSafeGet
INFO: could not read column value from result set: I1_0_0_; Invalid column name
Feb 5, 2009 11:23:43 AM org.hibernate.util.JDBCExceptionReporter logExceptions
WARNING: SQL Error: 17006, SQLState: null
Feb 5, 2009 11:23:43 AM org.hibernate.util.JDBCExceptionReporter logExceptions
SEVERE: Invalid column name
Exception :org.hibernate.exception.GenericJDBCException: could not execute query


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 05, 2009 3:02 am 
Regular
Regular

Joined: Thu Sep 06, 2007 2:22 am
Posts: 108
Location: Noida,India
Could you please try with this mapping..

Code:
<hibernate-mapping>
  <class entity-name="testhibernateapp.Catalog" table="P_CATALOG">
    <composite-id>
      <key-property column="I_COMPANY" name="company" type="double"/>
      <key-property column="I_SEASON" name="season" type="double"/>
      <key-property column="I_CATALOG" name="catalog" type="double"/>
    </composite-id>
    <property column="S_CATALOGNAME" name="catalogname" type="string"/>
    <property column="I_CIRCULATION_ACT" name="circulationAct" type="double"/>
  </class>
  <sql-query name="catalogBySeason">
   <return class="testhibernateapp.Catalog" alias="c"/>
    SELECT p.I_COMPANY AS {c.company} FROM P_CATALOG p
  </sql-query>
</hibernate-mapping>



Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 05, 2009 5:03 am 
Newbie

Joined: Wed Feb 04, 2009 3:22 am
Posts: 3
If I select all the column then its working fine.
Code:
<sql-query name="catalogBySeason">
   <return class="testhibernateapp.Catalog" alias="c"/>
     SELECT p.I_COMPANY ,p.I_SEASON,p.I_CATALOG,p.S_CATALOGNAME,p.I_CIRCULATION_ACT FROM P_CATALOG p
  </sql-query>


But If I miss any one of the column then its complaining.
Code:
<sql-query name="catalogBySeason">
   <return class="testhibernateapp.Catalog" alias="c"/>
     SELECT p.I_COMPANY, p.I_SEASON FROM P_CATALOG p
  </sql-query>

Code:
Hibernate:
    SELECT
        p.I_COMPANY ,
        p.I_SEASON
    FROM
        P_CATALOG p
Feb 5, 2009 2:29:04 PM org.hibernate.type.NullableType nullSafeGet
INFO: could not read column value from result set: I_CATALOG; Invalid column name
Feb 5, 2009 2:29:04 PM org.hibernate.util.JDBCExceptionReporter logExceptions
WARNING: SQL Error: 17006, SQLState: null
Feb 5, 2009 2:29:04 PM org.hibernate.util.JDBCExceptionReporter logExceptions
SEVERE: Invalid column name
Exception :org.hibernate.exception.GenericJDBCException: could not execute query


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 05, 2009 6:59 am 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
Since you are saying

Code:
<return class="testhibernateapp.Catalog" alias="c"/>


your query needs to include all column that are needed for the Catalog entity. If you only want some of the column you should use <return-scalar> instead. See http://www.hibernate.org/hib_docs/v3/re ... eries.html for more information.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.