Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

dettection of duplicate contacts

 
Nrapendra Sharma
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I want to detect duplicate contacts in my db. Duplicates can be on the basis of name, email, mobilenumber ...
And finally i want result in form of a collection of group.
e.g Group1 with common name n1 containing contacts founded by this name,
Group2 with common name n2 containing contacts founded by this name,
Group3 with common email e1 containing contacts founded by this email .. and so on

What will be the best way of doing it using hibernate. ???

Regards,
Nrapendra.
 
Andreas Erber
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Nrapendra Sharma,

it would possibly be the same as in SQL, use a count() query on each of your fields in question. Something like
I haven't tested this code, not even syntax checked.

This should give you a two column result set with the first column providing the value and the second the count how often it occurs.
I'd suggest a single query for each of the fields - otherwise it gets rather complicated.

CU
Froestel
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!