java - Hibernate: find duplicates -
Assume that I have a lower Groovy class (or equivalent in Java)
class User {long ID string name}
I would like to write the hibernate query (either HQL or benchmark) which gives at least one user all users with the same name.
Update
The following query has been suggested
Choose the minimum user (user.id), user users Username Username group grouping (user.name) & gt; However, there are some problems with this: - This does not actually return user objects, only their ID and name
- If there are 3 users of the same name, it will only return the ID of one of them, while I want all 3
- This will not work on MySQL, which is RDBMS I.
Thank you, Don
I will try something like this: / P>
select minimum (user.id), user.name user.name From user.name count count (user.name) & gt; According to 1
, SQL functions and consolidated tasks are allowed by the clause and in sequence if they are supported by the underlying database (i.e., not in MySQL). Edit
Edit: It is possible to recover users with IN (I do not think the query will be very good):
Users
Comments
Post a Comment