-->
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.  [ 3 posts ] 
Author Message
 Post subject: Problem whit ORDER BY
PostPosted: Fri Jun 17, 2011 10:13 pm 
Newbie

Joined: Fri Apr 29, 2011 3:21 pm
Posts: 6
My eviroment:

Hibernate 3.6.1
Hibernate tools 3.4.0
Eclipse helios

The problem:

select p.nombreproducto as nombre from Producto p order by nombre desc

this doesnt work hibernate tools throws this execption:

org.hibernate.exception.SQLGrammarException: could not execute query
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:92)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.loader.Loader.doList(Loader.java:2452)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2192)
at org.hibernate.loader.Loader.list(Loader.java:2187)
...


com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'nombre' in 'order clause'
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
...

This some strange since the SQL that the Dinamic SQL preview show is:

0: string
-----------------
select
producto0_.nombreproducto as col_0_0_
from
Producto producto0_
order by
nombre desc


col_0_0_ ? i told to it is an alias 'nombre'

why?


Top
 Profile  
 
 Post subject: Re: Problem whit ORDER BY
PostPosted: Fri Jun 17, 2011 10:27 pm 
Newbie

Joined: Fri Apr 29, 2011 3:21 pm
Posts: 6
select sum(v.total) as h from Venta v order by col_0_0_

and it works but if i put an h not
lol

why this happens?


Top
 Profile  
 
 Post subject: Re: Problem whit ORDER BY
PostPosted: Mon Jun 20, 2011 4:10 am 
Senior
Senior

Joined: Tue Aug 04, 2009 7:45 am
Posts: 124
Use "order by p.nombreproducto" in first example


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