-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: WrongClassException
PostPosted: Thu Nov 11, 2004 12:08 am 
Newbie

Joined: Wed Nov 10, 2004 11:24 pm
Posts: 1
Location: Sydney
This is a weird one, does anyone have any idea what could be causing this? I'm running Hibernate 2.1.6 against Postgres 7.4

Link has a many-to-one relation to Content. There are many subclasses of content (Page, Comment, etc), but the relation is defined as beeing to the Content superclass.

The problem occurs when I do a simple query that pulls back a large number of links. When Hibernate is processing the query, it throws this exception:

Code:
org.springframework.orm.hibernate.HibernateObjectRetrievalFailureException: Object with id: 159 was not of the specified subclass: com.atlassian.confluence.pages.Comment (loaded object was of wrong class); nested exception is net.sf.hibernate.WrongClassException: Object with id: 159 was not of the specified subclass: com.atlassian.confluence.pages.Comment (loaded object was of wrong class)
net.sf.hibernate.WrongClassException: Object with id: 159 was not of the specified subclass: com.atlassian.confluence.pages.Comment (loaded object was of wrong class)
   at net.sf.hibernate.loader.Loader.instanceAlreadyLoaded(Loader.java:531)
   at net.sf.hibernate.loader.Loader.getRow(Loader.java:498)
   at net.sf.hibernate.loader.Loader.getRowFromResultSet(Loader.java:213)
   at net.sf.hibernate.loader.Loader.doQuery(Loader.java:281)
   at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
   at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:911)
   at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:931)
   at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:59)
   at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:51)
   at net.sf.hibernate.persister.EntityPersister.load(EntityPersister.java:419)
   at net.sf.hibernate.impl.SessionImpl.doLoad(SessionImpl.java:2117)
   at net.sf.hibernate.impl.SessionImpl.doLoadByClass(SessionImpl.java:1991)
   at net.sf.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:1953)
   at net.sf.hibernate.type.ManyToOneType.resolveIdentifier(ManyToOneType.java:69)
   at net.sf.hibernate.type.EntityType.resolveIdentifier(EntityType.java:204)
   at net.sf.hibernate.impl.SessionImpl.initializeEntity(SessionImpl.java:2205)
   at net.sf.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:315)
   at net.sf.hibernate.loader.Loader.doQuery(Loader.java:305)
   at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
   at net.sf.hibernate.loader.Loader.doList(Loader.java:1033)
   at net.sf.hibernate.loader.Loader.list(Loader.java:1024)
   at net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:854)
   at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1544)
   at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:39)


From messing with the debugger, it looks like it's resolving the many-to-one link, but for some reason it's convinced that the far end of the link is going to be a Comment. Looking at the database, the row with id 159 is definitely a Page.

The problem is reproducible even when I shut the app down and restart, performing just this operation from a clean cache.

There is no mention of Comment anywhere in Link's mapping file, where could Hibernate be getting this misconception from? Any tips to where I should be looking?
Code:


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 11, 2004 3:12 am 
Expert
Expert

Joined: Thu Jan 29, 2004 2:31 am
Posts: 362
Location: Switzerland, Bern
Are you using subclassing? I've seen this error if you have unmapped discriminator values.
According to the docs you should be able to set force="true" to make hibernate using only mapped discriminator values, but for me this didn't help.

HTH
Ernst


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.