XStream
  1. XStream
  2. XSTR-664

ClassCastException in HibernatePersistentSortedSetConverter and HibernatePersistentSortedMapConverter

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.4, 1.4.1
    • Fix Version/s: 1.4.2
    • Component/s: Converters
    • Labels:
      None
    • JDK version and platform:
      Sun/Oracle 1.6.0_24 for Windows, 64bit

      Description

      A ClassCastException occurs when using a sorted map or sorted set with Hibernate and the XStream Hibernate extension package. The exception happens as an attempt is made to cast org.hibernate.collection.PersistentSortedSet to java.util.TreeSet or to cast org.hibernate.collection.PersistentSortedMap to java.util.TreeMap.

      The Hibernate collection classes }} and {{ do not inherit from TreeSet or TreeMap; they use them internally as a backing store only.

      The fix and work around for the problem is to wrap the PersistentSortedSet into a TreeSet and PersistentSortedMap into a TreeMap. This allows the super classes of HibernatePersistentSortedSetConverter and TreeMapConverter to perform the proper cast.

      I attached a test class that demonstrates the problem, as well as the proposed solution.

        People

        • Assignee:
          Jörg Schaible
          Reporter:
          Francis Henninger
        • Votes:
          0 Vote for this issue
          Watchers:
          1 Start watching this issue

          Dates

          • Created:
            Updated:
            Resolved: