Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: 3.1.3
Full stack trace of any exception that occurs:
java.lang.ClassCastException: x.Foo
at org.hibernate.criterion.Example.getEntityMode(Example.java:247)
at org.hibernate.criterion.Example.toSqlString(Example.java:177)
at org.hibernate.loader.criteria.CriteriaQueryTranslator.getWhereCondition(CriteriaQueryTranslator.java:333)
at org.hibernate.loader.criteria.CriteriaJoinWalker.<init>(CriteriaJoinWalker.java:82)
at org.hibernate.loader.criteria.CriteriaLoader.<init>(CriteriaLoader.java:67)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1514)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283)
i am seeing something i don't understand. i can work around it, but i am posting here in case someone wise has good advice or is otherwise interested.
i created a new view in my database which is a join of a master table and the 'latest' entry in a child table in a typical 1-to-n relationship. so i copied my old Foo.hbm.xml class to a new one, LatestFoo.hbm.xml, with the temporal data added in. fine (i think). i then subclassed Foo.java to LatestFoo.java and added the fields. compiled and started up the application. i have a query-by-example for a specific Foo object in my startup, and my app now fails (stacktrace chunk above).
from what i can tell, and again i am in over my head so i don't know what the intention is here, but SessionImpl.list now has two implementors for the Foo class (since LatestFoo extends Foo), but the Example.getEntityMode used in my criteria query call ends up asking the PojoInstantiator for LatestFoo if it is a Foo, and it says 'no', thus the class cast exception.