My problem is that i have a result set returned from an oracle stored procedure , and i do not have an id field ( in that particular resultset ) .
How can i generate an id field localy ? Because it seems that the <class> mapping cannot do without an id field .
Mapping documents:
Code:
<class name="ro.iss.view.chart.AdHocReportMonthly" table="ad_hoc_report">
<id name="id" type="java.lang.Long">
<generator class="native"/>
</id>
<property name="refDate" column="ref_date" type="java.lang.String" />
<property name="processType" column="process_type" type="java.lang.String" />
<property name="donor" column="donor" type="java.lang.String" />
<property name="status" column="status" type="java.lang.String" />
<property name="amount" column="amount" type="java.lang.Integer" />
</class>
Code between sessionFactory.openSession() and session.close():Code:
session = HibernateUtil.getCurrentSession();
Query portinstatus =session.getNamedQuery("monthly_report");
portinstatus.setParameter("status", "%" );
portinstatus.setParameter("fromdate", "09-10-2007");
portinstatus.setParameter("todate", "11-10-2007");
portinstatus.setParameter("process_type", "%");
portinstatus.setParameter("donor_id","%");
portinstatus.setParameter("target_date","START_DATE");
portinstatus.setParameter("granularity","NUMBER");
logger.debug("\n"+portinstatus.toString());
logger.debug("Getting list () ");
portInStatusList = portinstatus.list();
Full stack trace of any exception that occurs:Code:
[LongType][12 Oct 2007 11:34:38.848][Thread http-0.0.0.0-8080-1][ INFO] could not read column value from result set: id19_0_; Invalid column name
[AbstractBatcher][12 Oct 2007 11:34:38.849][Thread http-0.0.0.0-8080-1][DEBUG] about to close ResultSet (open ResultSets: 1, globally: 1)
[AbstractBatcher][12 Oct 2007 11:34:38.849][Thread http-0.0.0.0-8080-1][DEBUG] about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
[AbstractBatcher][12 Oct 2007 11:34:38.849][Thread http-0.0.0.0-8080-1][DEBUG] closing statement
[JDBCExceptionReporter][12 Oct 2007 11:34:38.859][Thread http-0.0.0.0-8080-1][DEBUG] could not execute query [{ call AD_HOC_REPORT_MONTHLY( ? ,?,?, ?,?, ? ,
?,?) }]
java.sql.SQLException: Invalid column name
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:269)
at oracle.jdbc.driver.OracleStatement.get_column_index(OracleStatement.java:5971)
at oracle.jdbc.driver.OracleResultSetImpl.findColumn(OracleResultSetImpl.java:1527)
at oracle.jdbc.driver.OracleResultSet.getLong(OracleResultSet.java:1540)
at org.hibernate.type.LongType.get(LongType.java:28)
at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:163)
at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:154)
Name and version of the database you are using:
Oracle 10g
Thank you.