org.hibernate.WrongClassException: Object [id=4010] was not of the specified subclass [B2] : loaded object was of wrong class class B1

Searched on Google with the first line of a JAVA stack trace?

We can recommend more relevant solutions and speed up debugging when you paste your entire stack trace with the exception message. Try a sample exception.

Recommended solutions based on your search

Solutions on the web

via Hibernate JIRA by Sergiu Hlihor, 1 year ago
Object [id=4010] was not of the specified subclass [B2] : loaded object was of wrong class class B1
via Hibernate JIRA by Sergiu Hlihor, 1 year ago
Object [id=4010] was not of the specified subclass [B2] : loaded object was of wrong class class B1
via Stack Overflow by Ben Kirby
, 2 years ago
Object with id: gM4pnnoRge4Odx4lUTZNMQ was not of the specified subclass: my.package.SubClassTwo (loaded object was of wrong class class my.package.SubClassOne)
via Stack Overflow by Alberson Melo
, 2 years ago
Object with id: 11952 was not of the specified subclass: VtigerAccountbillads (loaded object was of wrong class class VtigerAccountshipads)
via Google Groups by Tony Nelson, 2 years ago
Object with id: 1 was not of the specified subclass: Category (loaded object was of wrong class class coldfusion.orm.PersistentTemplateProxy)
via Coderanch by Oliver Li, 1 year ago
Object with id: 4 was not of the specified subclass: model.environment.impacts.measurement.TransformerLossConsumption (loaded object was of wrong class)
org.hibernate.WrongClassException: Object [id=4010] was not of the specified subclass [B2] : loaded object was of wrong class class B1
at org.hibernate.loader.Loader.instanceAlreadyLoaded(Loader.java:1550)
at org.hibernate.loader.Loader.getRow(Loader.java:1503)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:725)
at org.hibernate.loader.Loader.processResultSet(Loader.java:952)
at org.hibernate.loader.Loader.doQuery(Loader.java:920)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:354)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:324)
at org.hibernate.loader.collection.plan.LegacyBatchingCollectionInitializerBuilder$LegacyBatchingCollectionInitializer.initialize(LegacyBatchingCollectionInitializerBuilder.java:100)
at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:693)
at org.hibernate.event.internal.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:92)
at org.hibernate.internal.SessionImpl.initializeCollection(SessionImpl.java:1897)
at org.hibernate.collection.internal.AbstractPersistentCollection$4.doWork(AbstractPersistentCollection.java:558)
at org.hibernate.collection.internal.AbstractPersistentCollection.withTemporarySessionIfNeeded(AbstractPersistentCollection.java:260)
at org.hibernate.collection.internal.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:554)
at org.hibernate.collection.internal.AbstractPersistentCollection.read(AbstractPersistentCollection.java:142)

Users with the same issue

You are the first who have seen this exception.

Write tip

Know the solutions? Share your knowledge to help other developers to debug faster.