I need to find value duplicate count in the database use an HQL query instead of reading in an iterating over lots of objects.
The query should only count records whose field values match.
It should compare all but a specified list of fields. This will allow the developer to tell it to ignore things like the id, version and relationship fields.
Importantly this will not include embedded element collections. Is the following a correct approach?
Code:
select count(*) from Entity where valueField1 = vf1 and valueField2 = vf2 and elementCollection1 = ec1
Where vf1, vf2 and ec1 have been taken from the object to get the value duplicate count of.
As an aside is there anyway of specifying which fields to ignore instead of which to include.