gloeglm wrote:
Is the order by really not included in the generated SQL?
Thanks for the reply.
Here's my generated sql code:
Code:
Hibernate: select documento0_.id as id0_, versaodocu1_.id as id1_, versaodocu1_.documento_fk as document2_1_, documento0_.nome as nome0_, documento0_.descricao as descricao0_, documento0_.user_id as user_id0_, documento0_.dt_hr as dt_hr0_, documento0_.pasta_documento_fk as pasta_do6_0_, versaodocu1_.descricao as descricao1_, versaodocu1_.user_submissao as user_sub4_1_, versaodocu1_.data_submissao as data_sub5_1_, versaodocu1_.aprovado as aprovado1_, versaodocu1_.user_aprovacao as user_apr7_1_, versaodocu1_.data_aprovacao as data_apr8_1_, versaodocu1_.user_id as user_id1_, versaodocu1_.dt_hr as dt_hr1_, versaodocu1_.id as id__, versaodocu1_.documento_fk as document2___ from documento documento0_ inner join versao_documento versaodocu1_ on documento0_.id=versaodocu1_.documento_fk where (documento0_.id=? ) order by versaodocu1_.id asc
Hibernate: select documento0_.id as id3_, documento0_.nome as nome3_, documento0_.descricao as descricao3_, documento0_.user_id as user_id3_, documento0_.dt_hr as dt_hr3_, documento0_.pasta_documento_fk as pasta_do6_3_, docproxver1_.documento_fk as document1_0_, docproxver1_.versao_actual as versao_a2_0_, docproxver1_.user_id as user_id0_, docproxver1_.dt_hr as dt_hr0_, pastasdocu2_.id as id1_, pastasdocu2_.nome as nome1_, pastasdocu2_.descricao as descricao1_, pastasdocu2_.user_id as user_id1_, pastasdocu2_.dt_hr as dt_hr1_, pastasdocu2_.pasta_documento_fk as pasta_do6_1_, pastasdocu3_.id as id2_, pastasdocu3_.nome as nome2_, pastasdocu3_.descricao as descricao2_, pastasdocu3_.user_id as user_id2_, pastasdocu3_.dt_hr as dt_hr2_, pastasdocu3_.pasta_documento_fk as pasta_do6_2_ from documento documento0_ left outer join doc_prox_versao docproxver1_ on documento0_.id=docproxver1_.documento_fk left outer join pastas_documento pastasdocu2_ on documento0_.pasta_documento_fk=pastasdocu2_.id left outer join pastas_documento pastasdocu3_ on pastasdocu2_.pasta_documento_fk=pastasdocu3_.id where documento0_.id=?
What's strange is that the
order by appears in the generated sql code!
But in my prints to console, I'm getting:
Code:
----- DOCUMENTO -----
ID: 3 + NOME: xpto.pdf
------ VERSAO_DOCUMENTO ------
ID: 2 ++ DESC: bbb
ID: 1 ++ DESC: aaa
------------------------------------
As you can see, my
VERSAO_DOCUMENTO aren't appearing orderd ASC.
I've tried putting "
order-by="id asc"" in the mapping file for the "set" and that works ok. But I rather want to define my order by's in the code.
Any ideas?