HHH-13281 - Avoid ClassCastException when unwrapping EntityManager to deprecated org.hibernate.ejb.HibernateEntityManager.

This commit is contained in:
Chris Cranford 2019-02-20 17:13:04 -05:00 committed by gbadner
parent 819f92c425
commit 6813d1f488
2 changed files with 51 additions and 1 deletions

View File

@ -15,8 +15,8 @@ import javax.persistence.criteria.Selection;
import org.hibernate.HibernateException;
import org.hibernate.LockOptions;
import org.hibernate.StaleStateException;
import org.hibernate.ejb.HibernateEntityManager;
import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.jpa.HibernateEntityManager;
import org.hibernate.query.Query;
import org.hibernate.query.criteria.internal.ValueHandlerFactory;
import org.hibernate.type.Type;

View File

@ -0,0 +1,50 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.test.jpa;
import org.hibernate.Session;
import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
import org.junit.Test;
import org.hibernate.testing.TestForIssue;
/**
* @author Chris Cranford
*/
public class EntityManagerUnwrapTest extends BaseEntityManagerFunctionalTestCase {
@Test
@TestForIssue(jiraKey = "HHH-13281")
public void testUnwrapEjbHibernateEntityManagerInterface() {
org.hibernate.ejb.HibernateEntityManager em = getOrCreateEntityManager().unwrap( org.hibernate.ejb.HibernateEntityManager.class );
}
@Test
@TestForIssue(jiraKey = "HHH-13281")
public void testUnwrapJpaHibernateEntityManagerInterface() {
org.hibernate.jpa.HibernateEntityManager em = getOrCreateEntityManager().unwrap( org.hibernate.jpa.HibernateEntityManager.class );
}
@Test
@TestForIssue(jiraKey = "HHH-13281")
public void testUnwrapSessionImplementor() {
SessionImplementor session = getOrCreateEntityManager().unwrap( SessionImplementor.class );
}
@Test
@TestForIssue(jiraKey = "HHH-13281")
public void testUnwrapSession() {
Session session = getOrCreateEntityManager().unwrap( Session.class );
}
@Test
@TestForIssue(jiraKey = "HHH-13281")
public void testUnwrapSharedSessionContractImplementor() {
SharedSessionContractImplementor session = getOrCreateEntityManager().unwrap( SharedSessionContractImplementor.class );
}
}