[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-2352) ClassCastException in Session.get()

Alexey Romanchuk (JIRA) noreply at atlassian.com
Wed Jan 10 22:29:44 EST 2007


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-2352?page=comments#action_25778 ] 

Alexey Romanchuk commented on HHH-2352:
---------------------------------------

In javadoc for get function we see:
"Return the persistent instance of the given entity class with the given identifier, or null if there is no such persistent instance"
Due this description hibernate should return null but not object of other class. This may affect find() function of entity manager.

> ClassCastException in Session.get()
> -----------------------------------
>
>          Key: HHH-2352
>          URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2352
>      Project: Hibernate3
>         Type: Bug

>   Components: core
>     Versions: 3.2.1
>  Environment: Hibernate 3.2.1
>     Reporter: Alexey Romanchuk
>     Priority: Critical

>
>
> We have inheritance with joined-subclass mapping. Imagine that we have parent class - BaseObject and two subclasses - Client and Item. We enable second level cache on BaseObject. 
> try to load Client in first session 
> Client client = ( Client ) s1.get( Client.class, 1851727l );
> after this we have this client in second level cache.
> Next - load another subclass with same id:
> Item item = ( Item ) s2.get( Item.class, 1851727l );
> and here we have ClassCastException because hibernate found BaseObject (Client) and return it instead of null.
> The solution is class check in org.hibernate.event.def.DefaultLoadEventListener.loadFromSecondLevelCache() function. This is crititcal bug that violates Session API.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira




More information about the hibernate-issues mailing list