JPQLQuery loses nulls last/first for nested properties #1503

Closed
arivi opened this Issue Aug 28, 2015 · 1 comment

Projects

None yet

2 participants

@arivi
arivi commented Aug 28, 2015

I'm trying to generate a JPQLQuery which is order by a field in nested property. So I do something like this:

.orderBy(device.status.connectionTime.desc().nullsLast())

And the relevant part in the resulting sql looks like this:

order by devic1_.connection_time desc  

So the nulls last is missing.

Looking at my debugger, I can see that the place where the null handling value is reset is the com.mysema.query.support.QueryMixin -class.

public final T orderBy(OrderSpecifier<?> spec) {
        Expression<?> e = convert(spec.getTarget(), true);
        if (!spec.getTarget().equals(e)) {
            metadata.addOrderBy(new OrderSpecifier(spec.getOrder(), e));
        } else {
            metadata.addOrderBy(spec);
        }
        return self;
    }

It seems that after the conversion, the first branch gets chosen and there is a call to the two argument OrderSpecifier -constructor that looks like this:

public OrderSpecifier(Order order, Expression<T> target) {
        this(order, target, NullHandling.Default);        
    }

So much for my nulls last then.. Shouldn't the orderBy -method in the QueryMixin -class also copy the null handling value over to the new OrderSpecifier?

@timowest timowest added the bug label Aug 28, 2015
@timowest
Member

Thanks for the bug report! Fixed for Querydsl 3 and 4.

@timowest timowest added the progress label Aug 29, 2015
@johnktims johnktims closed this in #1504 Aug 31, 2015
@timowest timowest added this to the 4.0.4 milestone Aug 31, 2015
@timowest timowest removed the progress label Aug 31, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment