AbstractPersistentCollection.SetProxy does not implement equals()

Description

AbstractPersistentCollection.SetProxy implements java.util.Set interface, but does not define equals(), so this set cannot be properly compared.

Example:

I have a persistent Map, and invoke keySet() twice, each invocation returns new instance of SetProxy. If I perform equals() for these two sets after it, I have false.

Environment

None

Activity

Show:
Max Rydahl Andersen
December 9, 2005, 12:59 PM

this seem to be the case for all the <somecollection>Proxy classes in AbstractPersistentCollection....

Brett Meyer
April 7, 2014, 5:43 PM

In an effort to clean up, in bulk, tickets that are most likely out of date, we're transitioning all ORM 3 tickets to an "Awaiting Test Case" state. Please see http://in.relation.to/Bloggers/HibernateORMJIRAPoliciesAndCleanUpTactics for more information.

If this is still a legitimate bug in ORM 4, please provide either a test case that reproduces it or enough detail (entities, mappings, snippets, etc.) to show that it still fails on 4. If nothing is received within 3 months or so, we'll be automatically closing them.

Thank you!

Brett Meyer
July 8, 2014, 3:11 PM

Bulk rejecting stale issues. If this is still a legitimate issue on ORM 4, feel free to comment and attach a test case. I'll address responses case-by-case. Thanks!

Nikolai Schreier
June 9, 2017, 9:24 AM

This is still an issue in Hibernate 4 and 5 (up to 5.2.2).
And it is actually a bit worse than the original reporter stated. The SetProxy implementation actually breaks the contract of java.util.Set.equals():

Compares the specified object with this set for equality. Returns true if the specified object is also a set, the two sets have the same size, and every member of the specified set is contained in this set (or equivalently, every member of this set is contained in the specified set). This definition ensures that the equals method works properly across different implementations of the set interface.

I will attach test cases as soon as I can (either that is not possible for closed tickets or I don't have the permission yet).

Rejected

Assignee

Unassigned

Reporter

Vitaliy S

Fix versions

None

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure