Java Collections.binarySearch() returns null
<p>I have a list of objects and Comparator which is used for sorting and serching in that list. Collections.binarySearch() return null while it supposed to return an integer value. Here is the code :</p>

<pre><code>List&lt;AttribRow&gt; rows =  new ArrayList&lt;AttribRow&gt; ();
AttribRow temp = new AttribRow();
temp.setIndv1((long)22);
rows.add(temp);
temp = new AttribRow();
temp.setIndv1((long)22);
rows.add(temp);
temp = new AttribRow();
temp.setIndv1((long)22);
rows.add(temp);
temp = new AttribRow();
temp.setIndv1((long)23);
rows.add(temp);
temp = new AttribRow();
temp.setIndv1((long)22);
rows.add(temp);

temp = new AttribRow();
temp.setIndv1((long)25);
temp.setId((long)55);
Collections.sort(rows, new CitRowsComparator());
int index = 0;
index = Collections.binarySearch(rows, temp,new CitRowsComparator()); 
</code></pre>

<p>AttribRow is entity bean class mapped to the table. It has a field indv1 which is used in comparison.</p>

<pre><code>private Long indv1;
public Long getIndv1() {
    return indv1;
}

public void setIndv1(Long indv1) {
    this.indv1 = indv1;
}
</code></pre>

<p>This is a code for Comporator class</p>

<pre><code>public class CitRowsComparator implements Comparator&lt;AttribRow&gt; {
    public CitRowsComparator() {
        super();
    }

    public int compare(AttribRow one, AttribRow two) {
        return one.getIndv1().compareTo(two.getIndv1());
    }
}
</code></pre>

<p>Collections.binarySearch() alsways returns null. Even when I changed compare() method in Comparator to return 0 it was still returning null. Object temp thaht used as a key is also null after binarySearch envocation. I don't ge any expetions. I tried the same code for other class with one field and it worked fine. 
Any help will be appreciated.</p>
