Interesting you don't complain about the same happening from loading by id.  As I said above, I think this is the correct behavior.  Imo you are looking at it from your specific perspective, which is fine, but here you are asking Hibernate to load something as a particular type which (when it is cached) Hibernate knows it is not.  That is the definition of an exception to me.


On Sun, Dec 17, 2017, 5:55 AM Samuel Andersson (JIRA) <jira@hibernate.atlassian.net> wrote:
Samuel Andersson commented on Bug HHH-11532
 
Re: Loading extended entity by natural ID of base entity that exists in second level cache throws WrongClassException

Are you saying that throwing an exception (sometimes) when cache is enabled and returning null when it's disabled is correct? Should I, as a user of hibernate, have to catch this exception + check for null when I call this method? I don't really care whether an exception is thrown or not, but in my opinion behavior should be consistent regardless of 2nd level cache being enabled or not.

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100075-sha1:240e3d8)
Atlassian logo
_______________________________________________
hibernate-issues mailing list
hibernate-issues@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/hibernate-issues