Avoid proxy replacement for generic return type signatures
Issue: SPR-15010
(cherry picked from commit 6d1cae2)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,9 +16,13 @@
|
||||
|
||||
package org.springframework.orm.jpa.hibernate;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
|
||||
import org.hibernate.ejb.HibernateEntityManager;
|
||||
import org.hibernate.ejb.HibernateEntityManagerFactory;
|
||||
|
||||
import org.springframework.aop.framework.ProxyFactory;
|
||||
import org.springframework.aop.target.SingletonTargetSource;
|
||||
import org.springframework.orm.jpa.AbstractContainerEntityManagerFactoryIntegrationTests;
|
||||
import org.springframework.orm.jpa.EntityManagerFactoryInfo;
|
||||
|
||||
@@ -48,4 +52,14 @@ public class HibernateEntityManagerFactoryIntegrationTests extends
|
||||
assertNotNull(hibernateEntityManager.getSession());
|
||||
}
|
||||
|
||||
public void testCanUnwrapAopProxy() {
|
||||
EntityManager em = entityManagerFactory.createEntityManager();
|
||||
EntityManager proxy = ProxyFactory.getProxy(EntityManager.class, new SingletonTargetSource(em));
|
||||
assertTrue(em instanceof HibernateEntityManager);
|
||||
assertFalse(proxy instanceof HibernateEntityManager);
|
||||
assertTrue(proxy.unwrap(HibernateEntityManager.class) instanceof HibernateEntityManager);
|
||||
assertSame(em, proxy.unwrap(HibernateEntityManager.class));
|
||||
assertSame(em.getDelegate(), proxy.getDelegate());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user