I'm using Hibernate 2.1.2.
NOTE:
The query presented is very simplified for reading purposes. I want to make a complex query using
createSQLQuery because I can't make it work in plain HQL. With the more complex query I get the same error below.
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.
Need help on this please.
I'm stuck.