java.lang.ClassCastException: org.hibernate.internal.StatelessSessionImpl cannot be cast to org.hibernate.Session

Stack Overflow | longtimer | 10 months ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    StatelessSession being cast to Session in AbstractEntityPersister (Hibernate)

    Stack Overflow | 10 months ago | longtimer
    java.lang.ClassCastException: org.hibernate.internal.StatelessSessionImpl cannot be cast to org.hibernate.Session

    Root Cause Analysis

    1. java.lang.ClassCastException

      org.hibernate.internal.StatelessSessionImpl cannot be cast to org.hibernate.Session

      at org.hibernate.persister.entity.AbstractEntityPersister.preInsertInMemoryValueGeneration()
    2. Hibernate
      StatelessSessionImpl.insert
      1. org.hibernate.persister.entity.AbstractEntityPersister.preInsertInMemoryValueGeneration(AbstractEntityPersister.java:3591)
      2. org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3568)
      3. org.hibernate.internal.StatelessSessionImpl.insert(StatelessSessionImpl.java:144)
      4. org.hibernate.internal.StatelessSessionImpl.insert(StatelessSessionImpl.java:123)
      4 frames
    3. com.mycompany.somepackage
      DaPostInsertUpdateEventListener.onPostInsert
      1. com.mycompany.somepackage.dao.impl.CommonDAOImpl.persist2(CommonDAOImpl.java:242)
      2. com.mycompany.somepackage.publisher.ScJournalPublisher.publish(ScJournalPublisher.java:37)
      3. com.mycompany.somepackage.annotation.callback.CallbackInvoker.invokePublisherCallback(CallbackInvoker.java:92)
      4. com.mycompany.somepackage.event.listener.DaPostInsertUpdateEventListener.onPostInsert(DaPostInsertUpdateEventListener.java:51)
      4 frames
    4. Hibernate
      AbstractTransactionImpl.commit
      1. org.hibernate.action.internal.EntityInsertAction.postInsert(EntityInsertAction.java:177)
      2. org.hibernate.action.internal.EntityInsertAction.execute(EntityInsertAction.java:145)
      3. org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:465)
      4. org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:351)
      5. org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:350)
      6. org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:56)
      7. org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1258)
      8. org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:425)
      9. org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.beforeTransactionCommit(JdbcTransaction.java:101)
      10. org.hibernate.engine.transaction.spi.AbstractTransactionImpl.commit(AbstractTransactionImpl.java:177)
      10 frames
    5. Spring ORM
      HibernateTransactionManager.doCommit
      1. org.springframework.orm.hibernate4.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:584)
      1 frame
    6. Spring Tx
      TransactionInterceptor.invoke
      1. org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:757)
      2. org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:726)
      3. org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:521)
      4. org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:291)
      5. org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
      5 frames
    7. Spring AOP
      CglibAopProxy$DynamicAdvisedInterceptor.intercept
      1. org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
      2. org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:653)
      2 frames