Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

AndreTheHunter opened this issue Aug 1, 2013 · 1 comment


Copy link

@AndreTheHunter AndreTheHunter commented Aug 1, 2013

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
Copy link

@timowest 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
None yet
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants