1 Reply Latest reply on Sep 11, 2009 12:57 PM by cash1981

    How to Get Distinct from lists

      Hi


            I have a list...In that list There are 5 employees means...Each employee comes 5 times...From that i need distinct from that...How it possible...

        • 1. Re: How to Get Distinct from lists
          cash1981

          I dont understand your question. However I will try to answer what I understand.


          If you want a distinct list from a query, if you are using mysql you can write.



          entityManager.createQuery("SELECT DISTINCT p FROM Person p").getResultList();



          If you already have a List and you cannot do a query, then you can put the list in a Set and it will remove all duplicates.
          You need to then ensure that equals and hashcode is overrided and choose what is equal.