-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Possible BUG in createSQLQuery!
PostPosted: Thu Apr 08, 2004 4:41 am 
Pro
Pro

Joined: Wed Oct 08, 2003 10:31 am
Posts: 247
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?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.