1 Reply Latest reply on Jun 29, 2006 12:31 AM by Rob Jellinghaus

    ClassCastException: DelayedPostInsertIdentifier after going

    Rob Jellinghaus Novice

      Very confusing! I have some pretty straightforward code that worked fine with the 1.0beta2-era CVS build I had, but that now breaks after upgrading to 1.0.1:

      @Entity
      @Name("changeset")
      public class Changeset {
      ...
       private Long id;
      ...
       @Id @GeneratedValue
       public Long getId()
       {
       return id;
       }
      ...
       public List queryChangedObjects (Session database) {
       Query query = database.createQuery("from BlogPostImpl bp where bp.replicatedChangeset = :changeset")
       .setParameter("changeset", this);
       List ret = query.list();
       log.debug("Got list of changed objects in " + this + ", it's " + ret);
       return ret;
       }
      }

      The query.list() call breaks with this stacktrace:
      [testng] java.lang.ClassCastException: org.hibernate.action.DelayedPostInsertIdentifier
       [testng] at org.hibernate.type.LongType.set(LongType.java:42)
       [testng] at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:83)
       [testng] at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:65)
       [testng] at org.hibernate.type.ManyToOneType.nullSafeSet(ManyToOneType.java:77)
       [testng] at org.hibernate.loader.hql.QueryLoader.bindNamedParameters(QueryLoader.java:515)
       [testng] at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1577)
       [testng] at org.hibernate.loader.Loader.doQuery(Loader.java:661)
       [testng] at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
       [testng] at org.hibernate.loader.Loader.doList(Loader.java:2145)
       [testng] at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
       [testng] at org.hibernate.loader.Loader.list(Loader.java:2024)
       [testng] at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:392)
       [testng] at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:333)
       [testng] at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172)
       [testng] at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1114)
       [testng] at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
       [testng] at com.robjsoftware.replog.replicated.Changeset.queryChangedObjects(Changeset.java:77)
       [testng] at com.robjsoftware.replog.test.ChangesetTest$2.invokeApplication(ChangesetTest.java:77)
       [testng] at org.jboss.seam.mock.SeamTest$Script.run(SeamTest.java:242)
       [testng] at com.robjsoftware.replog.test.ChangesetTest.testChangeset(ChangesetTest.java:57)

      Why in heaven's name would this have worked up until I upgraded to 1.0.1??? The only changes I made in the upgrade were those necessary to get things compiling (e.g. adding @GeneratedValue, etc.). Where could this exception be coming from and how can I address it?

      I also posted to the Hibernate forum asking about this error, which one other person reported there after going to Hibernate 3.2CR2 (and got no reply to their report). (That post is here: http://forum.hibernate.org/viewtopic.php?p=2312158#2312158)

      Really not sure what to do about this. The Changeset I am calling queryChangedObjects on has definitely been persisted and flushed already by the time I call queryChangedObjects.

      Help?!
      Thanks,
      Rob

        • 1. Re: ClassCastException: DelayedPostInsertIdentifier after go
          Rob Jellinghaus Novice

          NEVER MIND, FIXED!

          Problem was that I am working in a noejb-like setting (I originally started from the old noejb example, now the hibernate example). In the course of porting to 1.0.1 I got confused and started making changes based on the booking example, with embeddedEjb rather than microcontainer. So I chopped out this method from the end of my test:

          @Override
           public SeamPhaseListener createPhaseListener()
           {
           return new SeamExtendedManagedPersistencePhaseListener();
           }

          Restoring that method fixed the exception. I twigged to this by rereading the Hibernate forum post that I followed up to, which mentioned that DelayedPostInsertIdentifier only is used by Hibernate when there is no outstanding transaction. Re-adding the createPhaseListener method caused there to be a transaction at this point in my test, as originally.

          Onwards :-)
          Cheers!
          Rob