-->
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.  [ 1 post ] 
Author Message
 Post subject: Problem with 'order by', multiple columns and Custom Type
PostPosted: Thu Jun 02, 2016 2:32 pm 
Newbie

Joined: Wed Oct 24, 2007 2:39 pm
Posts: 7
My Class:
Code:
public class Concurso {
private Long id;
private String nome;
private Date ultimaModificacao;
// getter & setters
}

My mapping:
Code:
<class name="Concurso" table="xyz">
        <id name="id" unsaved-value="null" type="long">
            <column name="ID"/>
        </id>
        <property name="nome"/>
        <property name="ultimaModificacao" type="MyDateTimeType">
            <column name="DT_ALTERACAO" not-null="true" sql-type="DATE"/>
            <column name="HR_ALTERACAO" not-null="true" sql-type="TIME"/>
        </property>
        <query name="find">
            from
                Concurso concurso
            order by
                concurso.ultimaModificacao desc
        </query>-->
</class>

My custom type 'MyDateTimeType' joins the 2 columns and builds (in the nullSafeGet method) a java.util.Date object to be configured in the 'Concurso' instances.

When I load the named query 'find' and execute the query.list(), the generated sql query is something like:
Code:
select
c.ID, c.DT_ALTERACAO, c.HR_ALTERACAO
from
xyz c
order by c.DT_ALTERACAO, c.HR_ALTERACAO desc

The problem is in the 'order' clause. Only the second column receives the 'desc' word. The correct should be:
Code:
select
c.ID, c.DT_ALTERACAO, c.HR_ALTERACAO
from
xyz c
order by c.DT_ALTERACAO DESC, c.HR_ALTERACAO DESC


What can I do to solve this?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.