javax.ejb.EJBException: java.lang.ClassCastException: ro.iqbyte.arhimed.model.core.common.entities.adm.Nurse

Hibernate JIRA | Antonel Pazargic | 1 decade ago
  1. 0

    I have the following hierarchy of entities MedicalPersonnel (abstract class) (InheritanceType.JOINED) >--- Nurse (concret class) >--- Physician (concrett class) and relation MedicalPersonnel (OneToMany) MedicalDoc When I've tried MedicalPersonnel mp; /* get a persisted and detached instance of MedicalPersonnel and assign with mp */ mp = em.merge(mp); //ClassCastException Error stack trace: Exception in thread "main" javax.ejb.EJBException: java.lang.ClassCastException: ro.iqbyte.arhimed.model.core.common.entities.adm.Nurse at org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:69) at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:83) at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:197) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:78) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:227) at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:106) at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:82) at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:828) at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:681) at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:358) at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:412) at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:239) Caused by: java.lang.ClassCastException: ro.iqbyte.arhimed.model.core.common.entities.adm.Nurse at org.hibernate.type.LongType.set(LongType.java:42) at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:83) at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:65) at org.hibernate.loader.Loader.bindPositionalParameters(Loader.java:1514) at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1576) at org.hibernate.loader.Loader.doQuery(Loader.java:661) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224) at org.hibernate.loader.Loader.loadEntity(Loader.java:1785) at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:48) at org.hibernate.loader.entity.EntityLoader.loadByUniqueKey(EntityLoader.java:85) at org.hibernate.persister.entity.AbstractEntityPersister.loadByUniqueKey(AbstractEntityPersister.java:1565) at org.hibernate.type.EntityType.loadByUniqueKey(EntityType.java:365) at org.hibernate.type.EntityType.resolve(EntityType.java:306) at org.hibernate.type.EntityType.replace(EntityType.java:207) at org.hibernate.type.TypeFactory.replace(TypeFactory.java:431) at org.hibernate.event.def.DefaultMergeEventListener.copyValues(DefaultMergeEventListener.java:282) at org.hibernate.event.def.DefaultMergeEventListener.entityIsDetached(DefaultMergeEventListener.java:246) at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:99) at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:51) at org.hibernate.impl.SessionImpl.fireMerge(SessionImpl.java:679) at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:663) at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:667) at org.hibernate.ejb.AbstractEntityManagerImpl.merge(AbstractEntityManagerImpl.java:201) at org.jboss.ejb3.entity.TransactionScopedEntityManager.merge(TransactionScopedEntityManager.java:181) at com.titan.services.TitanServiceBean.visitNurse(TitanServiceBean.java:122) at com.titan.services.TitanServiceBean.visitMedicalPersonnel(TitanServiceBean.java:116) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112) at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166) at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79) at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:197) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:78) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:227) at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:106) at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:82) at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:828) at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:681) at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:358) at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:412) at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:239) at org.jboss.remoting.RemoteClientInvoker.invoke(RemoteClientInvoker.java:190) at org.jboss.remoting.Client.invoke(Client.java:525) at org.jboss.remoting.Client.invoke(Client.java:488) at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:41) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88) at org.jboss.aspects.tx.ClientTxPropagationInterceptor.invoke(ClientTxPropagationInterceptor.java:46) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88) at org.jboss.aspects.security.SecurityClientInterceptor.invoke(SecurityClientInterceptor.java:40) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88) at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:78) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88) at org.jboss.ejb3.stateless.StatelessRemoteProxy.invoke(StatelessRemoteProxy.java:102) at $Proxy0.visitMedicalPersonnel(Unknown Source) at ro.iqbyte.arhimed.model.teste.Main.visitMedicalPersonnel(Main.java:196) at ro.iqbyte.arhimed.model.teste.Main.main(Main.java:71)

    Hibernate JIRA | 1 decade ago | Antonel Pazargic
    javax.ejb.EJBException: java.lang.ClassCastException: ro.iqbyte.arhimed.model.core.common.entities.adm.Nurse
  2. 0

    I have the following hierarchy of entities MedicalPersonnel (abstract class) (InheritanceType.JOINED) >--- Nurse (concret class) >--- Physician (concrett class) and relation MedicalPersonnel (OneToMany) MedicalDoc When I've tried MedicalPersonnel mp; /* get a persisted and detached instance of MedicalPersonnel and assign with mp */ mp = em.merge(mp); //ClassCastException Error stack trace: Exception in thread "main" javax.ejb.EJBException: java.lang.ClassCastException: ro.iqbyte.arhimed.model.core.common.entities.adm.Nurse at org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:69) at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:83) at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:197) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:78) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:227) at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:106) at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:82) at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:828) at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:681) at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:358) at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:412) at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:239) Caused by: java.lang.ClassCastException: ro.iqbyte.arhimed.model.core.common.entities.adm.Nurse at org.hibernate.type.LongType.set(LongType.java:42) at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:83) at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:65) at org.hibernate.loader.Loader.bindPositionalParameters(Loader.java:1514) at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1576) at org.hibernate.loader.Loader.doQuery(Loader.java:661) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224) at org.hibernate.loader.Loader.loadEntity(Loader.java:1785) at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:48) at org.hibernate.loader.entity.EntityLoader.loadByUniqueKey(EntityLoader.java:85) at org.hibernate.persister.entity.AbstractEntityPersister.loadByUniqueKey(AbstractEntityPersister.java:1565) at org.hibernate.type.EntityType.loadByUniqueKey(EntityType.java:365) at org.hibernate.type.EntityType.resolve(EntityType.java:306) at org.hibernate.type.EntityType.replace(EntityType.java:207) at org.hibernate.type.TypeFactory.replace(TypeFactory.java:431) at org.hibernate.event.def.DefaultMergeEventListener.copyValues(DefaultMergeEventListener.java:282) at org.hibernate.event.def.DefaultMergeEventListener.entityIsDetached(DefaultMergeEventListener.java:246) at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:99) at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:51) at org.hibernate.impl.SessionImpl.fireMerge(SessionImpl.java:679) at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:663) at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:667) at org.hibernate.ejb.AbstractEntityManagerImpl.merge(AbstractEntityManagerImpl.java:201) at org.jboss.ejb3.entity.TransactionScopedEntityManager.merge(TransactionScopedEntityManager.java:181) at com.titan.services.TitanServiceBean.visitNurse(TitanServiceBean.java:122) at com.titan.services.TitanServiceBean.visitMedicalPersonnel(TitanServiceBean.java:116) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112) at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166) at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79) at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:197) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:78) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:227) at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:106) at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:82) at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:828) at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:681) at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:358) at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:412) at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:239) at org.jboss.remoting.RemoteClientInvoker.invoke(RemoteClientInvoker.java:190) at org.jboss.remoting.Client.invoke(Client.java:525) at org.jboss.remoting.Client.invoke(Client.java:488) at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:41) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88) at org.jboss.aspects.tx.ClientTxPropagationInterceptor.invoke(ClientTxPropagationInterceptor.java:46) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88) at org.jboss.aspects.security.SecurityClientInterceptor.invoke(SecurityClientInterceptor.java:40) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88) at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:78) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88) at org.jboss.ejb3.stateless.StatelessRemoteProxy.invoke(StatelessRemoteProxy.java:102) at $Proxy0.visitMedicalPersonnel(Unknown Source) at ro.iqbyte.arhimed.model.teste.Main.visitMedicalPersonnel(Main.java:196) at ro.iqbyte.arhimed.model.teste.Main.main(Main.java:71)

    Hibernate JIRA | 1 decade ago | Antonel Pazargic
    javax.ejb.EJBException: java.lang.ClassCastException: ro.iqbyte.arhimed.model.core.common.entities.adm.Nurse
  3. 0

    I'm using Hibernate EntityManager 3.2CR2 inside JBoss EJB3 CR9. I'm invoking em.merge() with a detached object. The detached object has a 1:1 relationship with another detached object. The fetch strategy is the default strategy for 1:1 relationships. However, merge() fails and yields the stack trace below. When I enforce loading the referenced (and also detached) object, e.g. by em.find(), then there is no problem in invoking merge() afterwards. javax.ejb.EJBException: java.lang.ClassCastException: de.hska.kundenverwaltung.db.Firmenkunde at org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:69) at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:83) at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:197) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at org.jboss.aspects.security.RoleBasedAuthorizationInterceptor.invoke(RoleBasedAuthorizationInterceptor.java:167) at org.jboss.ejb3.security.RoleBasedAuthorizationInterceptor.invoke(RoleBasedAuthorizationInterceptor.java:108) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:78) at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:131) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101) at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:263) at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:106) at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:82) at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:828) at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:681) at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:358) at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:412) at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:239) Caused by: java.lang.ClassCastException: de.hska.kundenverwaltung.db.Firmenkunde at org.hibernate.type.LongType.set(LongType.java:42) at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:83) at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:65) at org.hibernate.loader.Loader.bindPositionalParameters(Loader.java:1513) at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1575) at org.hibernate.loader.Loader.doQuery(Loader.java:661) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224) at org.hibernate.loader.Loader.loadEntity(Loader.java:1784) at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:48) at org.hibernate.loader.entity.EntityLoader.loadByUniqueKey(EntityLoader.java:85) at org.hibernate.persister.entity.AbstractEntityPersister.loadByUniqueKey(AbstractEntityPersister.java:1581) at org.hibernate.type.EntityType.loadByUniqueKey(EntityType.java:365) at org.hibernate.type.EntityType.resolve(EntityType.java:306) at org.hibernate.type.EntityType.replace(EntityType.java:207) at org.hibernate.type.TypeFactory.replace(TypeFactory.java:437) at org.hibernate.event.def.DefaultMergeEventListener.copyValues(DefaultMergeEventListener.java:340) at org.hibernate.event.def.DefaultMergeEventListener.entityIsDetached(DefaultMergeEventListener.java:267) at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:120) at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:53) 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)

    Hibernate JIRA | 1 decade ago | Juergen Zimmermann
    javax.ejb.EJBException: java.lang.ClassCastException: de.hska.kundenverwaltung.db.Firmenkunde
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Well, I have an entity that stores a byte[] property as a Blob. @Lob @Basic(optional = false, fetch = FetchType.LAZY) public byte[] getContent() { return content; } The content can be pretty large, so I marked it as lazy and to enable lazy property fetching I am instrumenting the class at build-time using org.hibernate.tool.instrument.javassist.InstrumentTask just as the documentation says. However, when I call session.merge on this entity, I can get this stacktrace: java.lang.ClassCastException: org.hibernate.intercept.LazyPropertyInitializer$1 cannot be cast to [B at org.hibernate.type.AbstractLongBinaryType.toInternalFormat(AbstractLongBinaryType.java:46) at org.hibernate.type.AbstractBynaryType.isEqual(AbstractBynaryType.java:134) at org.hibernate.type.NullableType.isEqual(NullableType.java:233) at org.hibernate.type.MutableType.replace(MutableType.java:60) at org.hibernate.type.TypeFactory.replace(TypeFactory.java:548) at org.hibernate.event.def.DefaultMergeEventListener.copyValues(DefaultMergeEventListener.java:495) at org.hibernate.event.def.DefaultMergeEventListener.entityIsDetached(DefaultMergeEventListener.java:423) at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:234) at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:84) at org.hibernate.impl.SessionImpl.fireMerge(SessionImpl.java:859) at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:843) at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:847) It seems to work fine on session.get() I think it is a bug.

    Hibernate JIRA | 7 years ago | Kyrill Alyoshin
    java.lang.ClassCastException: org.hibernate.intercept.LazyPropertyInitializer$1 cannot be cast to [B
  6. 0

    Well, I have an entity that stores a byte[] property as a Blob. @Lob @Basic(optional = false, fetch = FetchType.LAZY) public byte[] getContent() { return content; } The content can be pretty large, so I marked it as lazy and to enable lazy property fetching I am instrumenting the class at build-time using org.hibernate.tool.instrument.javassist.InstrumentTask just as the documentation says. However, when I call session.merge on this entity, I can get this stacktrace: java.lang.ClassCastException: org.hibernate.intercept.LazyPropertyInitializer$1 cannot be cast to [B at org.hibernate.type.AbstractLongBinaryType.toInternalFormat(AbstractLongBinaryType.java:46) at org.hibernate.type.AbstractBynaryType.isEqual(AbstractBynaryType.java:134) at org.hibernate.type.NullableType.isEqual(NullableType.java:233) at org.hibernate.type.MutableType.replace(MutableType.java:60) at org.hibernate.type.TypeFactory.replace(TypeFactory.java:548) at org.hibernate.event.def.DefaultMergeEventListener.copyValues(DefaultMergeEventListener.java:495) at org.hibernate.event.def.DefaultMergeEventListener.entityIsDetached(DefaultMergeEventListener.java:423) at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:234) at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:84) at org.hibernate.impl.SessionImpl.fireMerge(SessionImpl.java:859) at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:843) at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:847) It seems to work fine on session.get() I think it is a bug.

    Hibernate JIRA | 7 years ago | Kyrill Alyoshin
    java.lang.ClassCastException: org.hibernate.intercept.LazyPropertyInitializer$1 cannot be cast to [B

    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.ClassCastException

      ro.iqbyte.arhimed.model.core.common.entities.adm.Nurse

      at org.hibernate.type.LongType.set()
    2. Hibernate
      TypeFactory.replace
      1. org.hibernate.type.LongType.set(LongType.java:42)
      2. org.hibernate.type.NullableType.nullSafeSet(NullableType.java:83)
      3. org.hibernate.type.NullableType.nullSafeSet(NullableType.java:65)
      4. org.hibernate.loader.Loader.bindPositionalParameters(Loader.java:1514)
      5. org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1576)
      6. org.hibernate.loader.Loader.doQuery(Loader.java:661)
      7. org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
      8. org.hibernate.loader.Loader.loadEntity(Loader.java:1785)
      9. org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:48)
      10. org.hibernate.loader.entity.EntityLoader.loadByUniqueKey(EntityLoader.java:85)
      11. org.hibernate.persister.entity.AbstractEntityPersister.loadByUniqueKey(AbstractEntityPersister.java:1565)
      12. org.hibernate.type.EntityType.loadByUniqueKey(EntityType.java:365)
      13. org.hibernate.type.EntityType.resolve(EntityType.java:306)
      14. org.hibernate.type.EntityType.replace(EntityType.java:207)
      15. org.hibernate.type.TypeFactory.replace(TypeFactory.java:431)
      15 frames
    3. Hibernate
      SessionImpl.merge
      1. org.hibernate.event.def.DefaultMergeEventListener.copyValues(DefaultMergeEventListener.java:282)
      2. org.hibernate.event.def.DefaultMergeEventListener.entityIsDetached(DefaultMergeEventListener.java:246)
      3. org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:99)
      4. org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:51)
      5. org.hibernate.impl.SessionImpl.fireMerge(SessionImpl.java:679)
      6. org.hibernate.impl.SessionImpl.merge(SessionImpl.java:663)
      7. org.hibernate.impl.SessionImpl.merge(SessionImpl.java:667)
      7 frames
    4. Hibernate EJB
      AbstractEntityManagerImpl.merge
      1. org.hibernate.ejb.AbstractEntityManagerImpl.merge(AbstractEntityManagerImpl.java:201)
      1 frame
    5. org.jboss.ejb3
      TransactionScopedEntityManager.merge
      1. org.jboss.ejb3.entity.TransactionScopedEntityManager.merge(TransactionScopedEntityManager.java:181)
      1 frame
    6. com.titan.services
      TitanServiceBean.visitMedicalPersonnel
      1. com.titan.services.TitanServiceBean.visitNurse(TitanServiceBean.java:122)
      2. com.titan.services.TitanServiceBean.visitMedicalPersonnel(TitanServiceBean.java:116)
      2 frames
    7. Java RT
      Method.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      4. java.lang.reflect.Method.invoke(Method.java:585)
      4 frames
    8. org.jboss.aop
      MethodInvocation.invokeNext
      1. org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
      1 frame
    9. org.jboss.ejb3
      EJB3InterceptorsInterceptor.invoke
      1. org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
      2. org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
      2 frames
    10. org.jboss.aop
      MethodInvocation.invokeNext
      1. org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      1 frame
    11. org.jboss.ejb3
      TransactionScopedEntityManagerInterceptor.invoke
      1. org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
      1 frame
    12. org.jboss.aop
      MethodInvocation.invokeNext
      1. org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      1 frame
    13. org.jboss.ejb3
      AllowedOperationsInterceptor.invoke
      1. org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
      1 frame
    14. org.jboss.aop
      MethodInvocation.invokeNext
      1. org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      1 frame
    15. org.jboss.aspects
      TxInterceptor$Required.invoke
      1. org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
      2. org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:197)
      2 frames
    16. org.jboss.aop
      MethodInvocation.invokeNext
      1. org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      1 frame
    17. org.jboss.aspects
      TxPropagationInterceptor.invoke
      1. org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
      1 frame
    18. org.jboss.aop
      MethodInvocation.invokeNext
      1. org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      1 frame
    19. org.jboss.ejb3
      StatelessInstanceInterceptor.invoke
      1. org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
      1 frame
    20. org.jboss.aop
      MethodInvocation.invokeNext
      1. org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      1 frame
    21. org.jboss.aspects
      AuthenticationInterceptor.invoke
      1. org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:78)
      1 frame
    22. org.jboss.aop
      MethodInvocation.invokeNext
      1. org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      1 frame
    23. org.jboss.ejb3
      ENCPropagationInterceptor.invoke
      1. org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47)
      1 frame
    24. org.jboss.aop
      MethodInvocation.invokeNext
      1. org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      1 frame
    25. org.jboss.ejb3
      AsynchronousInterceptor.invoke
      1. org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
      1 frame
    26. org.jboss.aop
      MethodInvocation.invokeNext
      1. org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      1 frame
    27. org.jboss.ejb3
      StatelessContainer.dynamicInvoke
      1. org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:227)
      1 frame
    28. org.jboss.aop
      Dispatcher.invoke
      1. org.jboss.aop.Dispatcher.invoke(Dispatcher.java:106)
      1 frame
    29. JBoss Application Server Aspects
      AOPRemotingInvocationHandler.invoke
      1. org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:82)
      1 frame
    30. org.jboss.remoting
      Client.invoke
      1. org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:828)
      2. org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:681)
      3. org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:358)
      4. org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:412)
      5. org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:239)
      6. org.jboss.remoting.RemoteClientInvoker.invoke(RemoteClientInvoker.java:190)
      7. org.jboss.remoting.Client.invoke(Client.java:525)
      8. org.jboss.remoting.Client.invoke(Client.java:488)
      8 frames
    31. JBoss Application Server Aspects
      InvokeRemoteInterceptor.invoke
      1. org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:41)
      1 frame
    32. org.jboss.aop
      MethodInvocation.invokeNext
      1. org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
      1 frame
    33. org.jboss.aspects
      ClientTxPropagationInterceptor.invoke
      1. org.jboss.aspects.tx.ClientTxPropagationInterceptor.invoke(ClientTxPropagationInterceptor.java:46)
      1 frame
    34. org.jboss.aop
      MethodInvocation.invokeNext
      1. org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
      1 frame
    35. org.jboss.aspects
      SecurityClientInterceptor.invoke
      1. org.jboss.aspects.security.SecurityClientInterceptor.invoke(SecurityClientInterceptor.java:40)
      1 frame
    36. org.jboss.aop
      MethodInvocation.invokeNext
      1. org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
      1 frame
    37. org.jboss.ejb3
      IsLocalInterceptor.invoke
      1. org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:78)
      1 frame
    38. org.jboss.aop
      MethodInvocation.invokeNext
      1. org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
      1 frame
    39. org.jboss.ejb3
      StatelessRemoteProxy.invoke
      1. org.jboss.ejb3.stateless.StatelessRemoteProxy.invoke(StatelessRemoteProxy.java:102)
      1 frame
    40. Unknown
      $Proxy0.visitMedicalPersonnel
      1. $Proxy0.visitMedicalPersonnel(Unknown Source)
      1 frame
    41. ro.iqbyte.arhimed
      Main.main
      1. ro.iqbyte.arhimed.model.teste.Main.visitMedicalPersonnel(Main.java:196)
      2. ro.iqbyte.arhimed.model.teste.Main.main(Main.java:71)
      2 frames