Issue Type: Bug Bug
Affects Versions: 4.2.0.CR1, 3.6.7
Assignee: Unassigned
Attachments: testcase.zip
Components: caching (L2)
Created: 05/Feb/13 11:26 PM
Description:

Consider three entities: Shape, Circle and Rectangle.

Circle and Rectangle are inherited from abstract class Shape using @Inheritance( strategy = InheritanceType.JOINED ). All three entities have persistent fields that are mapped to respective three database tables: shape, circle and rectangle. ID field is held in Shape entity. Circle and Rectangle use ID of the root entity Shape (via @PrimaryKeyJoinColumn).

PRECONDITIONS:

1. Let's there is a single Circle entity in the database with ID=1 and no Rectangles.
2. Let's this Circle entity is already in L2 cache.

SCENARIO 1:

1. Start a new session. This session does not have any entities in it's own cache yet.
2. Obtain a Rectangle with ID=1: session.get( Rectangle.class, 1L ) => returns Circle with ID=1. That's obviously wrong, because Rectangle is not a subclass or a superclass of Circle.

SCENARIO 2:

1. Check whether L2 cache has Rectangle with ID=1: sessionFactory().getCache().containsEntity( Rectangle.class, 1L ) => returns true, however should return false.

TestCase is in attachment.

Environment: Reproduced on Hibernate Core 3.6.7.Final and 4.2.0.CR1.
Project: Hibernate ORM
Labels: hibernate core
Priority: Major Major
Reporter: Dmitriy Dolovov
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira