Uploaded image for project: 'Hibernate ORM'
  1. HHH-3482

UnsupportedOperationException with StatelessSession

    Details

      Description

      When using a StatelessSession and saving a ManyToOne, we have an UnsupportedOperationException because of a call to getTimestamp() on the StatelessSession. May be the AbstractEntityPersister.isTransient() should always return null when dealing with a StatelessSession, since everything is transient in this case.

      StatelessSession s = getSessions().openStatelessSession();
      s.beginTransaction();
      Person p = new Person( new Long(1), "steve", 123 );
      s.insert(p);
      Order o = new Order( new Long(1), p );
      s.insert(o); // --> UnsupportedOperationException

      java.lang.UnsupportedOperationException
      at org.hibernate.impl.StatelessSessionImpl.getTimestamp(StatelessSessionImpl.java:435)
      at org.hibernate.persister.entity.AbstractEntityPersister.isTransient(AbstractEntityPersister.java:3422)
      at org.hibernate.engine.ForeignKeys.isTransient(ForeignKeys.java:204)
      at org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:241)
      at org.hibernate.type.EntityType.getIdentifier(EntityType.java:430)
      at org.hibernate.type.ManyToOneType.nullSafeSet(ManyToOneType.java:102)
      at org.hibernate.persister.entity.AbstractEntityPersister.dehydrate(AbstractEntityPersister.java:2045)
      at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2291)
      at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2708)
      at org.hibernate.impl.StatelessSessionImpl.insert(StatelessSessionImpl.java:117)
      at org.hibernate.impl.StatelessSessionImpl.insert(StatelessSessionImpl.java:99)
      at org.hibernate.test.timestampStateless.TimeStampProbTest.testTimeStampTest(TimeStampProbTest.java:28)

      You may see the joined test case.

      I found a old post on the forum with the same problem :
      http://forum.hibernate.org/viewtopic.php?p=2304937&sid=03c689ec5b12eebd8b26efa350241e80

      I hope this will help.

        Attachments

          Issue links

            Activity

              People

              • Votes:
                1 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: