-->
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.  [ 1 post ] 
Author Message
 Post subject: query-by-example and inherited class class cast exception
PostPosted: Fri Jul 21, 2006 6:14 pm 
Beginner
Beginner

Joined: Fri Oct 15, 2004 4:54 pm
Posts: 32
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.


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

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.