I am geting exception while doing a distinct query in named query. I have also specified the return-type tag. but I still get exception.
Below are my resource file, and the problem named query is 'GetAllRegion'
The resource files are
<?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="org" class="com.uscellular.shared.services.hibernate.Organization"/>
<![CDATA[ select org.organization_key AS {org.organizationKey},
org.region AS {org.region},
org.cluster_desc AS {org.clusterDesc},
org.submarket_id AS {org.submarketId},
org.submarket_desc AS {org.submarketDesc},
org.market_status AS {org.marketStatus},
org.data_center AS {org.dataCenter},
nvl(org.roaming_admin_fee,0) AS {org.roamingAdminFee},
nvl(org.network_surcharge,0) AS {org.networkSurcharge},
nvl(org.state_911_fee,0) AS {org.state911Fee},
nvl(org.state_911_fee_type,' ') AS {org.state911FeeType},
org.additional_comments AS {org.additionalComments} ,
org.cares_modification_date AS {org.caresModificationDate},
org.modification_date AS {org.modificationDate},
org.modification_user AS {org.modificationUser},
org.approval_date AS {org.approvalDate},
org.approval_user AS {org.approvalUser} ,
org.last_release_date AS {org.lastReleaseDate},
org.cluster_id AS {org.clusterId}
from organization org ]]>
</sql-query>
<sql-query name="GetAllRegion">
<return alias="a" class="com.uscellular.shared.services.hibernate.Organization">
<return-property name="region" column="region"></return-property>
</return>
<![CDATA[ select
a.region AS {a.region}
from organization a ]]>
</sql-query>
</hibernate-mapping>
Hibernate.cfg
====================
<?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 Exception I am getting for 'GetAllRegion' :-
Hibernate: select a.region AS region from organization a
<Jan 15, 2007 12:20:00 PM CST> <Warning> <org.hibernate.util.JDBCExceptionReporter> <000000> <SQL Error: 17006, SQLState
: null>
<Jan 15, 2007 12:20:00 PM CST> <Error> <org.hibernate.util.JDBCExceptionReporter> <000000> <Invalid column name>
<Jan 15, 2007 12:20:00 PM 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)
Can somebody please help .. what am I missing in this situation.
Thanks
Srikant
|