-->
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: Mon Apr 26, 2010 2:15 pm 
Newbie

Joined: Mon Apr 26, 2010 2:06 pm
Posts: 3
Hello,

I'm new in this forum , and also in hibernate.
i have this probleme whish i can't find a solution for it , i've seen several post in this forum about the same error but no one has given a right answer,

when i work without a resultSet it it looks fine ,i returned a List of Object . but when i use ResultSet to return a list of my Object , it doesn't work.

I execute my query with :

Code:
List<Category> itemList = findByNamedQuery("category.item.sql.querybyName", new Object[] {  });


This is my mapping file
Code:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
    <class name="com.bnpp.jdf.oco.dao.beo.Category" table="TB022_CATEGORY" schema="HR1">
        <id name="technicalIdentifier" type="big_decimal">
            <column name="TECHNICALIDENTIFIER" precision="22" scale="0" />
            <generator class="assigned" />
        </id>
       
        <property name="categoryLevel" type="integer">
            <column name="CATEGORYLEVEL" />
        </property>
       
        <many-to-one name="classification" class="com.bnpp.jdf.oco.dao.beo.Classification" fetch="select" cascade="all">
            <column name="CLASSIFICATIONTECHID" precision="22" scale="0" />
        </many-to-one>
        <many-to-one name="category" class="com.bnpp.jdf.oco.dao.beo.Category" fetch="select" cascade="save-update">
            <column name="PARENTCATEGORYTECHID" precision="22" scale="0" />
        </many-to-one>
       
      <component name="validityPeriod" class="com.bnpp.jdf.oco.dao.beo.Period">
       <property name="endDate" type="date">
            <column name="VALIDITY_ENDDATE" length="7" />
        </property>
        <property name="startDate" type="date">
            <column name="VALIDITY_STARTDATE" length="7" />
        </property>
       </component>
   
      <component name="labelsAndDescription" class="com.bnpp.jdf.oco.dao.beo.LabelsAndDescription">
       <property name="description" type="string">
            <column name="LAD_DESCRIPTION" length="4000" />
        </property>
        <property name="shortLabelCode" type="string">
            <column name="LAD_SHORTLABELCODE" length="5" />
        </property>
        <property name="longLabelCode" type="string">
            <column name="LAD_LONGLABELCODE" length="5" />
        </property>
       </component>
       
        <set name="childCategories" cascade="all" inverse="false">
             <key column="PARENTCATEGORYTECHID"/>
             <one-to-many class="com.bnpp.jdf.oco.dao.beo.Category"/>
        </set>
       
        <set name="items"  inverse="false" lazy="true" table="TB023_CATEGORY_ITEM" fetch="select" cascade="all" >
            <key>
                <column name="CATEGORYTECHID" precision="22" scale="0" not-null="true" />
            </key>
            <many-to-many entity-name="com.bnpp.jdf.oco.dao.beo.Item">
                <column name="ITEMTECHID" precision="22" scale="0" not-null="true" />
            </many-to-many>
        </set>
     </class>
     
     <resultset name="CategoryItem">
      <return alias="categoryItem" class="com.bnpp.jdf.oco.dao.beo.Category">
      </return>
   </resultset>
     
     <sql-query name="category.item.sql.querybyName" resultset-ref="CategoryItem" >
       
        <![CDATA[select TECHNICALIDENTIFIER ,CATEGORYLEVEL
      from TB022_CATEGORY
            ]]>
   </sql-query>

</hibernate-mapping>



and this is the error :
Code:

Exception in thread "main" org.springframework.jdbc.BadSqlGrammarException: Hibernate operation: could not execute query; bad SQL grammar [select TECHNICALIDENTIFIER ,CATEGORYLEVEL
      from TB022_CATEGORY]; nested exception is java.sql.SQLException: Nom de colonne non valide
   at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:220)
   at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72)
   at org.springframework.orm.hibernate3.HibernateAccessor.convertJdbcAccessException(HibernateAccessor.java:424)
   at org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:410)
   at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:424)
   at org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)
   at org.springframework.orm.hibernate3.HibernateTemplate.findByNamedQuery(HibernateTemplate.java:988)
   at com.bnpp.jdf.core.dao.impl.JdfAbstractDao.findByNamedQuery(JdfAbstractDao.java:75)
   at com.bnpp.jdf.oco.dao.impl.CategoryDaoImpl.getItemByCategoryId(CategoryDaoImpl.java:116)
   at com.bnpp.jdf.oco.test.main.dao.ClassificationDaoTestMain.getItemList(ClassificationDaoTestMain.java:314)
   at com.bnpp.jdf.oco.test.main.dao.ClassificationDaoTestMain.main(ClassificationDaoTestMain.java:43)
Caused by: java.sql.SQLException: Nom de colonne non valide
   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:3295)
   at oracle.jdbc.driver.OracleResultSetImpl.findColumn(OracleResultSetImpl.java:1914)
   at oracle.jdbc.driver.OracleResultSet.getInt(OracleResultSet.java:1563)
   at org.apache.commons.dbcp.DelegatingResultSet.getInt(DelegatingResultSet.java:237)
   at org.hibernate.type.IntegerType.get(IntegerType.java:28)
   at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:163)
   at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:189)
   at org.hibernate.loader.Loader.getInstanceClass(Loader.java:1442)
   at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1284)
   at org.hibernate.loader.Loader.getRow(Loader.java:1206)
   at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:580)
   at org.hibernate.loader.Loader.doQuery(Loader.java:701)
   at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
   at org.hibernate.loader.Loader.doList(Loader.java:2213)
   at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
   at org.hibernate.loader.Loader.list(Loader.java:2099)
   at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:289)
   at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1695)
   at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:142)
   at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:152)
   at org.springframework.orm.hibernate3.HibernateTemplate$33.doInHibernate(HibernateTemplate.java:997)
   at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:419)
   ... 6 more



Top
 Profile  
 
 Post subject: Re: invalid column name
PostPosted: Tue Apr 27, 2010 1:09 pm 
Newbie

Joined: Mon Apr 26, 2010 2:06 pm
Posts: 3
can any one help me ?


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.