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.
|