-->
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.  [ 6 posts ] 
Author Message
 Post subject: Newbie question: join
PostPosted: Fri Sep 30, 2005 2:00 pm 
Regular
Regular

Joined: Mon Aug 29, 2005 9:46 am
Posts: 102
Hello everyone,

I'm having problems with a simple join. I have the following statement, from a createQuery:

Code:

from FichaTecnica as f  join auge.bean.Produto as p  where upper(p.descricao) like upper(?)  order by descricao


and I get the error:

Code:
2005-09-30 14:47:32,328 ERROR StandardWrapper[/AugeProducao:action]  -> Servlet.service() for servlet action threw exception
java.lang.NullPointerException
        at org.hibernate.hql.ast.HqlSqlWalker.createFromJoinElement(HqlSqlWalker.java:264)
        at org.hibernate.hql.antlr.HqlSqlBaseWalker.joinElement(HqlSqlBaseWalker.java:3022)
        at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:2841)
        at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:2719)
        at


I don't know what's wrong, is it my HQL or my mapping files? I'll put them below:

Code:
  <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
         "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
 
<hibernate-mapping>
    <class name="auge.bean.FichaTecnica" table="FICHATECNICA" >
       <id name="fichaTecnica" column="fichaTecnica" type="java.lang.String">
           <generator class="assigned"/>
       </id>           
         
       <property name="molde" column="molde" type="java.lang.String" />
       <property name="tamanhoPiloto" column="tamanhoPiloto" type="java.lang.String" />
                                           
       <many-to-one name="estilista" column="estilista" class="auge.bean.Pessoa"
                    not-null="false" lazy="false"/>                       

       <many-to-one name="produto" column="produto" class="auge.bean.Produto"
                    not-null="false" lazy="false"/>                       
                                       
    </class>
</hibernate-mapping>


Code:
  <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
         "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
 
<hibernate-mapping>
    <class name="auge.bean.Produto" table="PRODUTOS" >
          <id name="produto" column="produto" type="java.lang.String">
              <generator class="assigned"/>
          </id>
       <property name="descricao" column="descricao" type="java.lang.String" />
               
    </class>   
</hibernate-mapping>


Could someone help? What's the right way for the HQL? Is mine right? Is my mapping files right?

I thank you all for the help


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 30, 2005 3:52 pm 
Regular
Regular

Joined: Mon Aug 29, 2005 9:46 am
Posts: 102
please?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 30, 2005 4:01 pm 
Expert
Expert

Joined: Wed Apr 06, 2005 5:03 pm
Posts: 273
Location: Salt Lake City, Utah, USA
Looks like you should have p.descricao, not just descricao, in your order by.

I don't see anything wrong with your mapping files at first glance.

I find that the new Hibernate Tools are very useful for getting your queries right. It will parse them into SQL on the fly, so you can immediately see if it's correct.

_________________
nathan


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 03, 2005 7:10 am 
Regular
Regular

Joined: Mon Aug 29, 2005 9:46 am
Posts: 102
I changed it, now it's:

Code:
from FichaTecnica as f  inner join f.produto as p  where upper(p.descricao) like upper(?)  order by p.descricao


and the same error is happening. Is it my hql?

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 03, 2005 6:09 pm 
Expert
Expert

Joined: Sat Jun 12, 2004 4:49 pm
Posts: 915
Try this :
Code:
from FichaTecnica as f  where upper(f.produto.descricao) like upper(?)  order by f.produto.descricao


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 04, 2005 12:54 pm 
Regular
Regular

Joined: Mon Aug 29, 2005 9:46 am
Posts: 102
it worked! thank you so much!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.