-->
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: Hibernate returning superclass when using Fetchmode.SELECT
PostPosted: Wed Dec 01, 2010 2:01 pm 
Newbie

Joined: Fri Jul 02, 2010 11:11 am
Posts: 4
Hi,

I have a super-class Contact and a subclass Phone, Email,etc
Now if I add @Fetch(value = FetchMode.SELECT ) to the getContactSet method the query return only the superclass of the record and I get the error Contact_$$_javassist_108 cannot be cast to Phone

@OneToMany(cascade = CascadeType.ALL, mappedBy = "activity", fetch = FetchType.EAGER, orphanRemoval = true)
@Fetch(value = FetchMode.SELECT )
public Set<Contact> getContactSet()
{
return contactSet;
}

Now if I don't do the Fetch Mode everything works correctly but the query that hibernate generate adds "left outer join" to the query statement. Now I have one main object with tons of property object like Contact which ends of generating one really long and slow sql statement with tons of "left outer join" which isn't really efficient. So I would like to use FetchMode.SELECT on all the objects since it generating separate statement and my speed is improve substantially but I'm getting the class cast exception. I am using the discriminator-column if that matters. Any body know what I am doing wrong or what I am missing?

Thank you.


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.