[jboss-user] [Persistence, JBoss/CMP, Hibernate, Database] - cast entity to Long

javatwo do-not-reply at jboss.com
Mon Jun 25 10:41:24 EDT 2007


When I merge entity Foo, got the following exception: trying to cast the entity to Long type, how could this be possible? 
Can someone give me some help on what might be the cause? Thanks! 

Caused by: java.lang.ClassCastException: xyz.Foo cannot be cast to java.lang.Long 
20:28:20,493 ERROR [STDERR] at org.hibernate.type.LongType.set(LongType.java:42) 
20:28:20,493 ERROR [STDERR] at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:83) 
20:28:20,494 ERROR [STDERR] at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:65) 
20:28:20,494 ERROR [STDERR] at org.hibernate.loader.Loader.bindPositionalParameters(Loader.java:1513) 
20:28:20,494 ERROR [STDERR] at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1575) 
20:28:20,494 ERROR [STDERR] at org.hibernate.loader.Loader.doQuery(Loader.java:661) 
20:28:20,494 ERROR [STDERR] at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224) 
20:28:20,494 ERROR [STDERR] at org.hibernate.loader.Loader.loadEntity(Loader.java:1784) 
20:28:20,494 ERROR [STDERR] at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:48) 
20:28:20,494 ERROR [STDERR] at org.hibernate.loader.entity.EntityLoader.loadByUniqueKey(EntityLoader.java:85) 
20:28:20,494 ERROR [STDERR] at org.hibernate.persister.entity.AbstractEntityPersister.loadByUniqueKey(AbstractEntityPersister.java:1581) 
20:28:20,494 ERROR [STDERR] at org.hibernate.type.EntityType.loadByUniqueKey(EntityType.java:365) 
20:28:20,494 ERROR [STDERR] at org.hibernate.type.EntityType.resolve(EntityType.java:306) 
20:28:20,494 ERROR [STDERR] at org.hibernate.type.EntityType.replace(EntityType.java:207) 
20:28:20,494 ERROR [STDERR] at org.hibernate.type.TypeFactory.replace(TypeFactory.java:437) 
20:28:20,494 ERROR [STDERR] at org.hibernate.event.def.DefaultMergeEventListener.copyValues(DefaultMergeEventListener.java:340) 
20:28:20,494 ERROR [STDERR] at org.hibernate.event.def.DefaultMergeEventListener.entityIsDetached(DefaultMergeEventListener.java:267) 
20:28:20,495 ERROR [STDERR] at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:120) 
20:28:20,495 ERROR [STDERR] at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:53) 
20:28:20,495 ERROR [STDERR] at org.hibernate.impl.SessionImpl.fireMerge(SessionImpl.java:677) 
20:28:20,495 ERROR [STDERR] at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:661) 
20:28:20,495 ERROR [STDERR] at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:665) 
20:28:20,495 ERROR [STDERR] at org.hibernate.ejb.AbstractEntityManagerImpl.merge(AbstractEntityManagerImpl.java:227) 
20:28:20,495 ERROR [STDERR] at org.jboss.ejb3.entity.TransactionScopedEntityManager.merge(TransactionScopedEntityManager.java:181)

----

Which Hibernate version(SVN revision) is used by JBoss4.0.5GA? Where to get the Hibernate source code. I need to debug it.

Thanks!
Dave

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4057379#4057379

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4057379



More information about the jboss-user mailing list