Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Java 9 Revealed this week in the Features new in Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Order by with two columns  RSS feed

 
Diego Gusava
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I have two objects

Objects: Objeto, Comunicado and ComunicadoTramite




The problem is, i want a list of Comunicado that is ordered by dataCriacao, the two objects (Comunicado and ComunicadoTramite) extends Objeto that contains dataCriacao.

if Comunicado.tramites.size() > 0 then get dataCriacao from the last ComunicadoTramite inserted

if Comunicado.tramites.size() = 0 then get dataCriacao from Comunicado.

Native SQL I did this




I dont know how to do it in JPA... can anyone help me?

 
Diego Gusava
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I did this

 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!