I have a program that compares objects from 2 databases.
I have objects from 2 different databases and I have to compare them. The problem is that hibernate returns a PersistentSet and this causes the program to fail as it only supports Java Collections.
Is there an elegant way to change this PersistentSet to HashSet. I have already tried Introspector approach but it still seems not to work with this comparator.
Your program is not supposed to depend directly on the
PersistentSetclass, that is considered an internal implementation detail of Hibernate.Instead, you should use the type
java.util.Setin your Java code (whichPersistentSetimplements).Just don't try to cast the
PersistentSettoHashSet. Instead assign it tojava.util.Set, as in all Hibernate code examples.