Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

[Hibernate]Order by using HQL

 
Rodrigo Vieira
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a simple HQL that works without error but hibernate doesn�t order my list. Is there any other way to do it then "order by"?

my hql:
FROM FrequenciaCrianca as fc WHERE fc.nucleo.codigo = 341 AND (fc.nucleoCrianca.dataTermino = null or fc.nucleoCrianca.dataTermino >= to_date('31/07/2008', 'dd/mm/yyyy')) AND fc.nucleoCrianca.dataInicio <= to_date('31/07/2008','dd/mm/yyyy')) order by fc.codCriancaPeti
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What kind of SQL is being kicked out by Hibernate. You might want to set the show_sql setting to true and see what is generated. Maybe even plug the SQL itself into a query tool and see what is happening. It really should work!

-Cameron McKenzie
 
Rodrigo Vieira
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
He create a lot of sql like this below, unfortunatelly we are force to use some tecnologies that don�t work like hibernate because of companies decisions. I am going to order manually to solve my problem. :/

select frequencia0_.CO_SEQ_FREQUENCIA as CO1_8_, frequencia0_.NU_MES_FREQUENCIA as NU2_96_8_, frequencia0_.NU_ANO_FREQUENCIA as NU3_96_8_, frequencia0_.DT_CADASTRO as DT4_96_8_, frequencia0_.ST_FREQUENTOU as ST5_96_8_, frequencia0_.CO_NIS_CRIANCA as CO6_96_8_, criancapet1_.CO_NIS_CRIANCA as CO1_0_, criancapet1_.NO_CRIANCA as NO2_93_0_, criancapet1_.DT_INICIO_PETI as DT3_93_0_, criancapet1_.DT_NASCIMENTO as DT4_93_0_, criancapet1_.VL_BOLSA as VL5_93_0_, criancapet1_.TP_BOLSA as TP6_93_0_, criancapet1_.CO_NIS_RESPONSAVEL_LEGAL as CO7_93_0_, criancapet1_.CO_CIDADE as CO8_93_0_, criancapet1_.CO_TIPO_TRABALHO as CO9_93_0_, responsave2_.CO_NIS_RESPONSAVEL_LEGAL as CO1_1_, responsave2_.NO_RESPONSAVEL_LEGAL as NO2_98_1_, responsave2_.NU_DOMICILIO as NU3_98_1_, cidade3_.CO_SEQ_CIDADE as CO1_2_, cidade3_.NO_CIDADE as NO2_17_2_, cidade3_.SG_CIDADE as SG3_17_2_, cidade3_.NU_DDD as NU4_17_2_, cidade3_.NU_CEP as NU5_17_2_, cidade3_.CO_MUNICIPIO_IBGE as CO6_17_2_, cidade3_.CO_MUNICIPIO_SIAFI as CO7_17_2_, cidade3_.ST_CAPITAL as ST8_17_2_, cidade3_.ST_REGISTRO_ATIVO as ST9_17_2_, cidade3_.NU_IBGE_GEO as NU10_17_2_, cidade3_.CO_IBGE_DV as CO11_17_2_, cidade3_.CO_PAIS as CO12_17_2_, cidade3_.ID_UF as ID13_17_2_, cidade3_.ID_PORTE_CIDADE as ID14_17_2_, pais4_.CO_SEQ_PAIS as CO1_3_, pais4_.NO_PAIS as NO2_20_3_, pais4_.CO_GRUPO_PAIS as CO3_20_3_, pais4_.DS_NACIONALIDADE as DS4_20_3_, pais4_.CO_PAIS_SIAPE as CO5_20_3_, pais4_.ST_REGISTRO_ATIVO as ST6_20_3_, uf5_.ID_UF as ID1_4_, uf5_.CO_UF as CO2_15_4_, uf5_.NO_UF as NO3_15_4_, uf5_.NU_ORDEM_REGIAO as NU4_15_4_, uf5_.DS_NATURALIDADE as DS5_15_4_, uf5_.CO_UF_SIAFI as CO6_15_4_, uf5_.CO_UF_INSS as CO7_15_4_, uf5_.CO_UF_LDO as CO8_15_4_, uf5_.ST_BRASILEIRA as ST9_15_4_, uf5_.CO_IBGE as CO10_15_4_, uf5_.CO_CIDADE_CAPITAL as CO11_15_4_, uf5_.CO_REGIAO_BRASIL as CO12_15_4_, regiao6_.CO_REGIAO_BRASIL as CO1_5_, regiao6_.NO_REGIAO_BRASIL as NO2_19_5_, regiao6_.CO_REGIAO_IBGE as CO3_19_5_, regiao6_.CO_REGIAO_SIAFI as CO4_19_5_, porte7_.ID_PORTE_CIDADE as ID1_6_, porte7_.DS_PORTE_CIDADE as DS2_16_6_, tipotrabal8_.CO_SEQ_TIPO_TRABALHO as CO1_7_, tipotrabal8_.DS_TIPO_TRABALHO as DS2_101_7_ from TB_FREQUENCIA_ASE frequencia0_, TB_CRIANCA_PETI criancapet1_, TB_RESPONSAVEL_LEGAL_PETI responsave2_, TB_CIDADE cidade3_, TB_PAIS pais4_, TB_UNIDADE_FEDERACAO uf5_, TB_REGIAO_BRASIL regiao6_, TB_PORTE_CIDADE porte7_, TB_TIPO_TRABALHO tipotrabal8_ where frequencia0_.CO_NIS_CRIANCA=criancapet1_.CO_NIS_CRIANCA(+) and criancapet1_.CO_NIS_RESPONSAVEL_LEGAL=responsave2_.CO_NIS_RESPONSAVEL_LEGAL(+) and criancapet1_.CO_CIDADE=cidade3_.CO_SEQ_CIDADE(+) and cidade3_.CO_PAIS=pais4_.CO_SEQ_PAIS(+) and cidade3_.ID_UF=uf5_.ID_UF(+) and uf5_.CO_REGIAO_BRASIL=regiao6_.CO_REGIAO_BRASIL(+) and cidade3_.ID_PORTE_CIDADE=porte7_.ID_PORTE_CIDADE(+) and criancapet1_.CO_TIPO_TRABALHO=tipotrabal8_.CO_SEQ_TIPO_TRABALHO(+) and frequencia0_.CO_SEQ_FREQUENCIA=?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic