I'm using Hibernate 2.1.2.
Here's my mapping file:
MpRequisicaoSq044
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<hibernate-mapping>
<class
name="vo.MpRequisicaoSq044"
table="mp_requisicao_sq044"
>
<id
name="id"
type="long"
column="id"
>
<generator class="increment" />
</id>
<property
name="dataRequisicao"
type="java.sql.Date"
column="data_requisicao"
not-null="true"
length="4"
/>
<property
name="estado"
type="java.lang.String"
column="estado"
length="1"
/>
<!-- associations -->
<!-- bi-directional one-to-many association to MpReqItem -->
<set
name="mpReqItems"
lazy="true"
inverse="true"
>
<key>
<column name="mp_requisicao_fk" />
</key>
<one-to-many
class="vo.MpReqItem"
/>
</set>
</class>
</hibernate-mapping>
-----------
CODE
-----------
Code:
( ... )
Query q = session.createSQLQuery("select {mr}.data_requisicao from mp_requisicao_sq044 {mr}", "mr", MpRequisicaoSq044.class);
List res = q.list();
( ... )
-------------------
DEBUG INFO
-------------------
Code:
( ... )
DEBUG: select mr.data_requisicao from mp_requisicao_sq044 mr
Hibernate: select mr.data_requisicao from mp_requisicao_sq044 mr
DEBUG: preparing statement
DEBUG: processing result set
DEBUG: SQL Exception
org.postgresql.util.PSQLException: The column name id0_ not found.
at org.postgresql.jdbc1.AbstractJdbc1ResultSet.findColumn(AbstractJdbc1ResultSet.java:673)
at org.postgresql.jdbc1.AbstractJdbc1ResultSet.getLong(AbstractJdbc1ResultSet.java:501)
( ... )
NOTE:
I have other business methods using this class with no problems at all. So the problem hasn't to do with the mapping (generated with R3) file or the generated VO.
I've tried it using plain JDBC calls and HQL and it works. So the problem has to do with the
createSQLQuery.
Has this been reported?