This content has been marked as final.
Show 1 reply
-
1. Re: How to Get Distinct from lists
cash1981 Sep 11, 2009 12:57 PM (in response to moyphus)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.