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: