Read the rules before posting!
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: 2.1.8
Mapping documents:
Code:
<class name="Facility" table="FMS_TBL_FACILITY">
<id name="facId" column="FACILITY_ID" type="long" unsaved-value="null">
<generator class="increment"/>
</id>
<set name="child" inverse="true" cascade="all">
<key column="PARENT_ID"/>
<one-to-many class="Facility"/>
</set>
<property name="parentId" column="PARENT_ID" type="long"/>
<property name="systemId" column="SYSTEM_ID" type="long"/>
<property name="desc" column="DESCRIPTION" type="string"/>
<property name="status" column="STATUS" type="string"/>
<property name="leafLevel" column="LEAF_LEVEL" type="integer"/>
</class>
Code between sessionFactory.openSession() and session.close():Code:
String sql = "select f.facility_id as {f.facId}, "
+ "f.parent_id as {f.parentId}, "
+ "f.description as {f.desc} "
+ "from fms_tbl_facility f "
+ "where f.facility_id=:facId";
List result = session.createSQLQuery(sql, "f", Facility.class)
.setLong("facId", facId.longValue()).list();
if(result.size() > 0)
fac = (Facility)result.toArray()[0];
Full stack trace of any exception that occurs:Code:
net.sf.hibernate.exception.SQLGrammarException: error performing findBySQL
at net.sf.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:69)
at net.sf.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29)
at net.sf.hibernate.impl.SessionImpl.convert(SessionImpl.java:4131)
at net.sf.hibernate.impl.SessionImpl.findBySQL(SessionImpl.java:3870)
at net.sf.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:52)
at com.psca.M27000.dao.M27000_DAO.getParent(M27000_DAO.java:398)
at com.psca.M27000.action.MasterFacilityOnLoad.getAncestors(MasterFacilityOnLoad.java:56)
at com.psca.M27000.action.MasterFacilityOnLoad.execute(MasterFacilityOnLoad.java:42)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:226)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:397)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:65)
at oracle.security.jazn.oc4j.JAZNFilter.doFilter(Unknown Source)
at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:649)
at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:322)
at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:790)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:270)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:112)
at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192)
at java.lang.Thread.run(Thread.java:534)
Caused by: java.sql.SQLException: Invalid column name
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:137)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:174)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:239)
at oracle.jdbc.driver.OracleStatement.get_column_index(OracleStatement.java:3155)
at oracle.jdbc.driver.OracleResultSetImpl.findColumn(OracleResultSetImpl.java:1896)
at oracle.jdbc.driver.OracleResultSet.getLong(OracleResultSet.java:1629)
at com.mchange.v2.c3p0.impl.NewProxyResultSet.getLong(NewProxyResultSet.java:2544)
at net.sf.hibernate.type.LongType.get(LongType.java:21)
at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:62)
at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:53)
at net.sf.hibernate.type.AbstractType.hydrate(AbstractType.java:67)
at net.sf.hibernate.loader.Loader.hydrate(Loader.java:690)
at net.sf.hibernate.loader.Loader.loadFromResultSet(Loader.java:631)
at net.sf.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:590)
at net.sf.hibernate.loader.Loader.getRow(Loader.java:505)
at net.sf.hibernate.loader.Loader.getRowFromResultSet(Loader.java:218)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:285)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:138)
at net.sf.hibernate.loader.Loader.doList(Loader.java:1063)
at net.sf.hibernate.loader.Loader.list(Loader.java:1054)
at net.sf.hibernate.loader.SQLLoader.list(SQLLoader.java:92)
at net.sf.hibernate.impl.SessionImpl.findBySQL(SessionImpl.java:3867)
Name and version of the database you are using: Oracle 9i
The generated SQL (show_sql=true):Code:
select f.facility_id as FACILITY1_0_, f.parent_id as PARENT_ID0_, f.description as DESCRIPT4_0_ from fms_tbl_facility f where f.facility_id=?
When I run the generated SQL in SQP Plus, it works correctly. Could you help me to find out what is wrong with my code and how to fix it. Thank you very much in advance.