Collection query distinct() throws java.lang.NullPointerException for nulls values #466

AndreTheHunter opened this Issue Aug 1, 2013 · 1 comment


None yet
2 participants

When using distinct with a collection query, if the first value is null, a NullPointerException is thrown.
e.g. for:

public class CollectionQueryDistinctNPE {
    public static class Example {

    public void test() throws Exception {
        final Example e = alias(Example.class, "example");
        final List<Example> examples = Arrays.asList(null, new Example(), null);
        from($(e), examples).distinct().list($(e));


    at com.mysema.query.collections.DefaultQueryEngine.distinct(
    at com.mysema.query.collections.DefaultQueryEngine.evaluateSingleSource(
    at com.mysema.query.collections.DefaultQueryEngine.list(
    at com.mysema.query.collections.AbstractCollQuery.list(

A suggested fix would be to add a null check at DefaultQueryEngine:97 :

if (!list.isEmpty() && list.get(0) != null && list.get(0).getClass().isArray()) {

timowest added a commit that referenced this issue Aug 1, 2013


This comment has been minimized.

Show comment
Hide comment

timowest Aug 27, 2013


Released in 3.2.3


timowest commented Aug 27, 2013

Released in 3.2.3

@timowest timowest closed this Aug 27, 2013

@timowest timowest added this to the 3.2.3 milestone Apr 13, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment