-->
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.  [ 2 posts ] 
Author Message
 Post subject: Problem with createSQLQuery
PostPosted: Wed Apr 07, 2004 5:10 am 
Pro
Pro

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


Top
 Profile  
 
 Post subject: Re: Problem with createSQLQuery
PostPosted: Wed Apr 07, 2004 6:13 am 
Pro
Pro

Joined: Wed Oct 08, 2003 10:31 am
Posts: 247
NOTE:
I've tried it using plain JDBC calls and it works.

Any ideas please?


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

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.