[hibernate-issues] [Hibernate-JIRA] Closed: (HHH-2348) <org.hibernate.util.JDBCExceptionReporter> <000000> <Invalid column name> Exception in Named Query

Max Rydahl Andersen (JIRA) noreply at atlassian.com
Tue Jan 9 04:26:44 EST 2007


     [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-2348?page=all ]
     
Max Rydahl Andersen closed HHH-2348:
------------------------------------

    Resolution: Rejected

read the docs and/or use the hibernate forums.

you are using column names where it should be property names in return-property

> <org.hibernate.util.JDBCExceptionReporter> <000000> <Invalid column name> Exception in Named Query
> --------------------------------------------------------------------------------------------------
>
>          Key: HHH-2348
>          URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2348
>      Project: Hibernate3
>         Type: Bug

>   Components: query-sql
>  Environment: Hibernate 3, Oracle9
>     Reporter: Srikant Panda

>
> Original Estimate: 4 hours
>         Remaining: 4 hours
>
> I am trying to use "getNamedQuery". When I run the SQL, as shown by putting the property "hibernate.show_sql" in config file, The SQL Runs perfectly fine. but in Hibernate it is throwing an exception of "invalid Column", What is annoying is , It worked fine when I was not using named query.
> below is the copy of my hibernate.cfg.xml
> ==============================
> <?xml version='1.0' encoding='UTF-8'?>
> <!DOCTYPE hibernate-configuration PUBLIC
>           "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
>           "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
> <!-- Generated by MyEclipse Hibernate Tools.                   -->
> <hibernate-configuration>
> 	<session-factory>
> 		<property name="connection.username">pdbread</property>
> 		<property name="connection.url">
> 			jdbc:oracle:thin:@chi1dds1:1521:pdbdev
> 		</property>
> 		<property name="dialect">
> 			org.hibernate.dialect.Oracle9Dialect
> 		</property>
> 		<property name="myeclipse.connection.profile">PDBDEV</property>
> 		<property name="connection.password">owner</property>
>       <property name="hibernate.show_sql">true</property>
> 		<property name="connection.driver_class">
> 			oracle.jdbc.driver.OracleDriver
> 		</property>
> 		<mapping resource="com/uscellular/shared/services/hibernate/Organization.hbm.xml" />
> 	</session-factory>
> </hibernate-configuration>
> ========================
> The Organization.hbm.xml file 
> =====================
> <?xml version="1.0"?>
> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
> "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
> <!-- 
>     Mapping file autogenerated by MyEclipse - Hibernate Tools
> -->
> <hibernate-mapping>
>     <class name="com.uscellular.shared.services.hibernate.Organization" table="ORGANIZATION" schema="PDBREAD">
>         <id name="organizationKey" type="java.lang.Long">
>             <column name="ORGANIZATION_KEY" precision="10" scale="0" />
>             <generator class="assigned" />
>         </id>
>         <property name="region" type="java.lang.String">
>             <column name="REGION" length="30" />
>         </property>
>         <property name="clusterDesc" type="java.lang.String">
>             <column name="CLUSTER_DESC" length="30" />
>         </property>
>         <property name="submarketId" type="java.lang.String">
>             <column name="SUBMARKET_ID" length="3" />
>         </property>
>         <property name="submarketDesc" type="java.lang.String">
>             <column name="SUBMARKET_DESC" length="30" />
>         </property>
>         <property name="marketStatus" type="java.lang.String">
>             <column name="MARKET_STATUS" length="1" />
>         </property>
>         <property name="dataCenter" type="java.lang.String">
>             <column name="DATA_CENTER" length="3" />
>         </property>
>         <property name="roamingAdminFee" type="java.lang.Double">
>             <column name="ROAMING_ADMIN_FEE" precision="9" />
>         </property>
>         <property name="networkSurcharge" type="java.lang.Double">
>             <column name="NETWORK_SURCHARGE" precision="9" />
>         </property>
>         <property name="state911Fee" type="java.lang.Double">
>             <column name="STATE_911_FEE" precision="9" />
>         </property>
>         <property name="state911FeeType" type="java.lang.String">
>             <column name="STATE_911_FEE_TYPE" length="3" />
>         </property>
>         <property name="additionalComments" type="java.lang.String">
>             <column name="ADDITIONAL_COMMENTS" length="2000" />
>         </property>
>         <property name="caresModificationDate" type="java.util.Date">
>             <column name="CARES_MODIFICATION_DATE" length="7" />
>         </property>
>         <property name="modificationDate" type="java.util.Date">
>             <column name="MODIFICATION_DATE" length="7" />
>         </property>
>         <property name="modificationUser" type="java.lang.String">
>             <column name="MODIFICATION_USER" length="10" />
>         </property>
>         <property name="approvalDate" type="java.util.Date">
>             <column name="APPROVAL_DATE" length="7" />
>         </property>
>         <property name="approvalUser" type="java.lang.String">
>             <column name="APPROVAL_USER" length="10" />
>         </property>
>         <property name="lastReleaseDate" type="java.util.Date">
>             <column name="LAST_RELEASE_DATE" length="7" />
>         </property>
>         <property name="clusterId" type="java.lang.Long">
>             <column name="CLUSTER_ID" precision="10" scale="0" not-null="true" />
>         </property>
>     </class>
> 	<sql-query name="GetAllOrganization">
> 	    <return alias="Organization" class="com.uscellular.shared.services.hibernate.Organization">
> 	    <return-property name="ORGANIZATION_KEY" column="organizationKey"/>
> 	    <return-property name="REGION" column="region"/>
> 	    <return-property name="CLUSTER_DESC" column="clusterDesc"/>
> 	    <return-property name="SUBMARKET_ID" column="submarketId"/>
> 	    <return-property name="SUBMARKET_DESC" column="submarketDesc"/>
> 	    <return-property name="MARKET_STATUS" column="marketStatus"/>
> 	    <return-property name="DATA_CENTER" column="dataCenter"/>
> 	    <return-property name="ROAMING_ADMIN_FEE" column="roamingAdminFee"/>
> 	    <return-property name="NETWORK_SURCHARGE" column="networkSurcharge"/>
> 	    <return-property name="STATE_911_FEE" column="state911Fee"/>
> 	    <return-property name="STATE_911_FEE_TYPE" column="state911FeeType"/>
> 	    <return-property name="ADDITIONAL_COMMENTS" column="additionalComments"/>
> 	    <return-property name="CARES_MODIFICATION_DATE" column="caresModificationDate"/>
> 	    <return-property name="MODIFICATION_DATE" column="modificationDate"/>
> 	    <return-property name="MODIFICATION_USER" column="modificationUser"/>
> 	    <return-property name="APPROVAL_DATE" column="approvalDate"/>
> 	    <return-property name="APPROVAL_USER" column="approvalUser"/>
> 	    <return-property name="LAST_RELEASE_DATE" column="lastReleaseDate"/>
> 	    <return-property name="CLUSTER_ID" column="clusterId"/>
> 	   	</return>
> 		select organization_key AS organizationKey, region AS region, cluster_desc AS clusterDesc, submarket_id AS submarketId, submarket_desc AS submarketDesc, market_status AS marketStatus, data_center AS dataCenter, nvl(roaming_admin_fee,0) AS roamingAdminFee, nvl(network_surcharge,0) AS networkSurcharge, nvl(state_911_fee,0) AS state911Fee, state_911_fee_type AS state911FeeType, additional_comments AS additionalComments, cares_modification_date AS caresModificationDate, modification_date AS modificationDate, modification_user AS modificationUser,  approval_date AS approvalDate, approval_user AS approvalUser, last_release_date AS lastReleaseDate, cluster_id AS clusterId from organization 
> 	</sql-query>
>     
> </hibernate-mapping>
> ===========================
> when I make a call like this
> >>>>
>     public Organization[] getAll() {
> 		List<Organization> retList;
> 		Organization[] org= null;
> 		try {
> 			org.hibernate.Session s = getSession();
> 			retList = s.getNamedQuery("GetAllOrganization").list();
> 			org = new Organization[retList.size()];
> 			retList.toArray(org);
>         } catch (RuntimeException re) {
>             log.error("get failed", re);
>             throw re;
>         }        
>         return org;
>     }
> >>>>>
> I get an Exception  as below
> Hibernate: select organization_key AS organizationKey, region AS region, cluster_desc AS clusterDesc, submarket_id AS submarketId, submarket_desc AS submarketDesc, market_status AS marketStatus, data_center AS dataCenter, nvl(roaming_admin_fee,0) AS roamingAdminFee, nvl(network_surcharge,0) AS networkSurcharge, nvl(state_911_fee,0) AS state911Fee, state_911_fee_type AS state911FeeType, additional_comments AS additionalComments, cares_modification_date AS caresModificationDate, modification_date AS modificationDate, modification_user AS modificationUser, approval_date AS approvalDate, approval_user AS approvalUser, last_release_date AS lastReleaseDate, cluster_id AS clusterId from organization
> <Jan 9, 2007 12:04:00 AM CST> <Warning> <org.hibernate.util.JDBCExceptionReporter> <000000> <SQL Error: 17006, SQLState: null>
> <Jan 9, 2007 12:04:00 AM CST> <Error> <org.hibernate.util.JDBCExceptionReporter> <000000> <Invalid column name>
> <Jan 9, 2007 12:04:00 AM CST> <Error> <com.uscellular.shared.services.hibernate.OrganizationDAO> <000000> <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:1518)
>         at org.hibernate.loader.Loader.list(Loader.java:1498)
>         at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:103)
>         Truncated. see log file for complete stacktrace
> 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:3291)
>         at oracle.jdbc.driver.OracleResultSetImpl.findColumn(OracleResultSetImpl.java:1914)
>         Truncated. see log file for complete stacktrace
> >
> 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:1518)
>         at org.hibernate.loader.Loader.list(Loader.java:1498)
>         at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:103)
>         at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1340)
>         at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:151)
>         at com.uscellular.shared.services.hibernate.OrganizationDAO.getAll(OrganizationDAO.java:68)
> Any help in this is appreciated, I am wondering, why this could be a problem, ( because of any mistake in my configuration or .hbm.xml file ) or something else. when the sql is perfectly running file
> I have tried to remove the 'AS'  clause in SQL - did not work
> I tried to put like ' ORGANIZATION_KEY AS Organization.organizationKey ' = did not work
> I tried to put ' From Organization org ' alias in table name - did not work
> I have tried putting the Oracle schema.table name in the query - Did not work.
> please help !!!!!!!!!!!!!!!!!! have already spent a week worth of time on this issue already.
> Thanks

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira




More information about the hibernate-issues mailing list