Hibernate Compare PersistentSet with HashSet

Antoine

I have a problem. In my JUnit test i want to test the insertion in my db done by hibernate. I got an entity which avec a Setlist and i want to see if the list inserted is equals to the list i've set.

assertEquals(listDerogationLinux, derogation.getListDerogationLinux());

The problem is that hibernate use PersistentSet and i use HashMap so when i try to compare them i got an AassertionError :

java.lang.AssertionError: expected: java.util.HashSet<[...]> but was: org.hibernate.collection.internal.PersistentSet<[...]>

I've tried a lot a things but the only thing that work is to make a new hashSet with the PersistentSet but it is really ugly ...

assertTrue(new HashSet<DerogationLinux>(derogation.getListDerogationLinux()).equals(listDerogationLinux));

Is there a better way ?

Avseiytsev Dmitriy

Try to call equals on PersistentSet instead of HashSet. It should work.

persistentSet.equals(hashSet)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Hibernate PersistentSet remove() operation not working

From Dev

HashSet in Hibernate

From Dev

Cant persist a Hashset in hibernate

From Dev

javax.el.PropertyNotFoundException: Property not found on type org.hibernate.collection.internal.PersistentSet

From Dev

Hibernate compare with empty List?

From Dev

How to compare a hashSet within a foreach loop iterating through another hashSet Java

From Dev

duplicate element in hashset ( after implementing comparator /compare method correctly )

From Dev

JPA Hibernate select distinct over @ElementCollection and compare

From Dev

Hibernate query date compare month only

From Dev

JDBC Hibernate Oracle extract database schema to compare changes

From Dev

Hibernate : HQL query to directly compare timestamp from database value

From Dev

Hibernate Validator - Compare two Dates - Class-Level constraint

From Dev

HashSet as key for other HashSet

From Dev

HashSet implementations

From Dev

Is there a HashSet in Delphi?

From Dev

HashSet or == sign

From Dev

HashSet of integers

From Dev

Implementing HashSet

From Dev

HashSet or == sign

From Dev

HashSet is empty

From Dev

How to compare objects with a Date variable (Hibernate)? java.util.Date vs java.sql.Timestamp

From Java

Is it possible that TreeSet equals HashSet but not HashSet equals TreeSet

From Dev

Can I pass a HashSet<SomeEnumeration> as HashSet<byte>?

From Dev

Delete hashset of actions from hashset of actions

From Dev

HashSet and TreeSet performance test

From Dev

HashSet<T> fundamental things

From Dev

Locking HashSet for concurrency

From Dev

HashSet for finding duplicate arrays

From Java

Define: What is a HashSet?

Related Related

HotTag

Archive