@Override
    public int compare(T obj1, T obj2) {
        if (obj1 == null) {
            return obj2 == null ? 0 : -1;
        } else if (obj2 == null) {
            return 1;
        } else {
            return obj1.compareTo(obj2);
        }
    }
NullSafeComparableComparator is a null safe comparator for Comparable objects

@author tiwe

@param <T>
querydsl-core/src/main/java/com/querydsl/core/util/NullSafeComparableComparator.java