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.
_______________________________________________
Samuel Andersson commented on 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
Get Jira notifications on your phone! Download the Jira Cloud app for Android or iOS
This message was sent by Atlassian Jira
hibernate-issues mailing list
hibernate-issues@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/hibernate-issues