java.lang.UnsupportedOperationException

Hibernate JIRA | Emmanuel Bernard | 1 decade ago
  1. 0

    Cat cat = new Cat(); cat.setId( new CatPk() ); cat.getId().setName( "titi" ); cat.getId().setThoroughbred( "unknown" ); Set<Woman> women = new HashSet<Woman>(); Woman woman = new Woman(); woman.setId( new WomanPk() ); woman.getId().setFirstName( "Lady" ); woman.getId().setLastName( "McBeth" ); women.add( woman ); cat.setHumanContacts( Collections.unmodifiableSet( women ) ); Set<Cat> cats = new HashSet<Cat>(); cats.add( cat ); woman.setCats( Collections.unmodifiableSet(cats) ); s.persist( cat ); s.persist( woman ); tx.commit(); s.merge( woman ); During merge, the entity is copied into itself (?) defaultmergeeventlistener.entityIsPersistent() => copyValues(persister, entity, entity, source, copyCache); java.lang.UnsupportedOperationException at java.util.Collections$UnmodifiableCollection.clear(Collections.java:1037) at org.hibernate.collection.PersistentSet.clear(PersistentSet.java:247) at org.hibernate.type.CollectionType.replaceElements(CollectionType.java:404) at org.hibernate.type.CollectionType.replace(CollectionType.java:449) at org.hibernate.type.TypeFactory.replace(TypeFactory.java:437) at org.hibernate.event.def.DefaultMergeEventListener.copyValues(DefaultMergeEventListener.java:282) at org.hibernate.event.def.DefaultMergeEventListener.entityIsPersistent(DefaultMergeEventListener.java:132) at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:105) at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:51) at org.hibernate.impl.SessionImpl.fireMerge(SessionImpl.java:677) at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:661) at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:665) at org.hibernate.test.annotations.manytomany.ManyToManyTest.testUnmodifiableCollection(ManyToManyTest.java:102) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at org.hibernate.test.annotations.TestCase.runTest(TestCase.java:67) at com.intellij.rt.execution.junit2.JUnitStarter.main(JUnitStarter.java:32) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90) What is the reason for that? The spec says that "If X is a managed entity, it is ignored by the merge operation"

    Hibernate JIRA | 1 decade ago | Emmanuel Bernard
    java.lang.UnsupportedOperationException
  2. 0

    Cat cat = new Cat(); cat.setId( new CatPk() ); cat.getId().setName( "titi" ); cat.getId().setThoroughbred( "unknown" ); Set<Woman> women = new HashSet<Woman>(); Woman woman = new Woman(); woman.setId( new WomanPk() ); woman.getId().setFirstName( "Lady" ); woman.getId().setLastName( "McBeth" ); women.add( woman ); cat.setHumanContacts( Collections.unmodifiableSet( women ) ); Set<Cat> cats = new HashSet<Cat>(); cats.add( cat ); woman.setCats( Collections.unmodifiableSet(cats) ); s.persist( cat ); s.persist( woman ); tx.commit(); s.merge( woman ); During merge, the entity is copied into itself (?) defaultmergeeventlistener.entityIsPersistent() => copyValues(persister, entity, entity, source, copyCache); java.lang.UnsupportedOperationException at java.util.Collections$UnmodifiableCollection.clear(Collections.java:1037) at org.hibernate.collection.PersistentSet.clear(PersistentSet.java:247) at org.hibernate.type.CollectionType.replaceElements(CollectionType.java:404) at org.hibernate.type.CollectionType.replace(CollectionType.java:449) at org.hibernate.type.TypeFactory.replace(TypeFactory.java:437) at org.hibernate.event.def.DefaultMergeEventListener.copyValues(DefaultMergeEventListener.java:282) at org.hibernate.event.def.DefaultMergeEventListener.entityIsPersistent(DefaultMergeEventListener.java:132) at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:105) at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:51) at org.hibernate.impl.SessionImpl.fireMerge(SessionImpl.java:677) at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:661) at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:665) at org.hibernate.test.annotations.manytomany.ManyToManyTest.testUnmodifiableCollection(ManyToManyTest.java:102) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at org.hibernate.test.annotations.TestCase.runTest(TestCase.java:67) at com.intellij.rt.execution.junit2.JUnitStarter.main(JUnitStarter.java:32) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90) What is the reason for that? The spec says that "If X is a managed entity, it is ignored by the merge operation"

    Hibernate JIRA | 1 decade ago | Emmanuel Bernard
    java.lang.UnsupportedOperationException
  3. 0

    Faces messages are not cleared on subsequent requests

    Stack Overflow | 5 years ago | MahmoudS
    java.lang.UnsupportedOperationException
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Warlock's Thoughts: JPA and unmodifiable collections

    blogspot.com | 4 weeks ago
    java.lang.UnsupportedOperationException

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.UnsupportedOperationException

      No message provided

      at java.util.Collections$UnmodifiableCollection.clear()
    2. Java RT
      Collections$UnmodifiableCollection.clear
      1. java.util.Collections$UnmodifiableCollection.clear(Collections.java:1037)
      1 frame
    3. Hibernate
      PersistentSet.clear
      1. org.hibernate.collection.PersistentSet.clear(PersistentSet.java:247)
      1 frame
    4. Hibernate
      TypeFactory.replace
      1. org.hibernate.type.CollectionType.replaceElements(CollectionType.java:404)
      2. org.hibernate.type.CollectionType.replace(CollectionType.java:449)
      3. org.hibernate.type.TypeFactory.replace(TypeFactory.java:437)
      3 frames
    5. Hibernate
      SessionImpl.merge
      1. org.hibernate.event.def.DefaultMergeEventListener.copyValues(DefaultMergeEventListener.java:282)
      2. org.hibernate.event.def.DefaultMergeEventListener.entityIsPersistent(DefaultMergeEventListener.java:132)
      3. org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:105)
      4. org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:51)
      5. org.hibernate.impl.SessionImpl.fireMerge(SessionImpl.java:677)
      6. org.hibernate.impl.SessionImpl.merge(SessionImpl.java:661)
      7. org.hibernate.impl.SessionImpl.merge(SessionImpl.java:665)
      7 frames
    6. org.hibernate.test
      ManyToManyTest.testUnmodifiableCollection
      1. org.hibernate.test.annotations.manytomany.ManyToManyTest.testUnmodifiableCollection(ManyToManyTest.java:102)
      1 frame
    7. Java RT
      DelegatingMethodAccessorImpl.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      3 frames
    8. org.hibernate.test
      TestCase.runTest
      1. org.hibernate.test.annotations.TestCase.runTest(TestCase.java:67)
      1 frame
    9. com.intellij.rt
      JUnitStarter.main
      1. com.intellij.rt.execution.junit2.JUnitStarter.main(JUnitStarter.java:32)
      1 frame
    10. Java RT
      DelegatingMethodAccessorImpl.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      3 frames
    11. IDEA
      AppMain.main
      1. com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)
      1 frame