DATAREST-1322 - Fix proxy detection for Hibernate 5+ compatibility.
Switched to Spring Data Commons' ProxyUtils for a proxy detection mechanism that supports Hibernate 5 proxies.
This commit is contained in:
@@ -27,8 +27,8 @@ import java.util.Set;
|
||||
|
||||
import org.springframework.core.annotation.AnnotationUtils;
|
||||
import org.springframework.data.rest.core.projection.ProjectionDefinitions;
|
||||
import org.springframework.data.util.ProxyUtils;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
@@ -164,7 +164,7 @@ public class ProjectionDefinitionConfiguration implements ProjectionDefinitions
|
||||
|
||||
Assert.notNull(sourceType, "Source type must not be null!");
|
||||
|
||||
Class<?> userType = ClassUtils.getUserClass(sourceType);
|
||||
Class<?> userType = ProxyUtils.getUserClass(sourceType);
|
||||
Map<String, ProjectionDefinition> byName = new HashMap<String, ProjectionDefinition>();
|
||||
Map<String, Class<?>> result = new HashMap<String, Class<?>>();
|
||||
|
||||
|
||||
@@ -34,17 +34,8 @@ import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.core.ResolvableType;
|
||||
import org.springframework.core.annotation.AnnotationAwareOrderComparator;
|
||||
import org.springframework.core.annotation.AnnotationUtils;
|
||||
import org.springframework.data.rest.core.annotation.HandleAfterCreate;
|
||||
import org.springframework.data.rest.core.annotation.HandleAfterDelete;
|
||||
import org.springframework.data.rest.core.annotation.HandleAfterLinkDelete;
|
||||
import org.springframework.data.rest.core.annotation.HandleAfterLinkSave;
|
||||
import org.springframework.data.rest.core.annotation.HandleAfterSave;
|
||||
import org.springframework.data.rest.core.annotation.HandleBeforeCreate;
|
||||
import org.springframework.data.rest.core.annotation.HandleBeforeDelete;
|
||||
import org.springframework.data.rest.core.annotation.HandleBeforeLinkDelete;
|
||||
import org.springframework.data.rest.core.annotation.HandleBeforeLinkSave;
|
||||
import org.springframework.data.rest.core.annotation.HandleBeforeSave;
|
||||
import org.springframework.data.rest.core.annotation.RepositoryEventHandler;
|
||||
import org.springframework.data.rest.core.annotation.*;
|
||||
import org.springframework.data.util.ProxyUtils;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
@@ -115,7 +106,7 @@ public class AnnotatedEventHandlerInvoker implements ApplicationListener<Reposit
|
||||
@Override
|
||||
public Object postProcessAfterInitialization(final Object bean, String beanName) throws BeansException {
|
||||
|
||||
Class<?> beanType = ClassUtils.getUserClass(bean);
|
||||
Class<?> beanType = ProxyUtils.getUserClass(bean);
|
||||
RepositoryEventHandler typeAnno = AnnotationUtils.findAnnotation(beanType, RepositoryEventHandler.class);
|
||||
|
||||
if (typeAnno == null) {
|
||||
|
||||
@@ -26,8 +26,8 @@ import java.util.Set;
|
||||
import org.springframework.data.mapping.PersistentEntity;
|
||||
import org.springframework.data.mapping.PersistentProperty;
|
||||
import org.springframework.data.mapping.context.PersistentEntities;
|
||||
import org.springframework.data.util.ProxyUtils;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
/**
|
||||
* {@link ResourceMappings} for {@link PersistentEntities}.
|
||||
@@ -63,7 +63,7 @@ public class PersistentEntitiesResourceMappings implements ResourceMappings {
|
||||
|
||||
Assert.notNull(type, "Type must not be null!");
|
||||
|
||||
type = ClassUtils.getUserClass(type);
|
||||
type = ProxyUtils.getUserClass(type);
|
||||
|
||||
if (cache.containsKey(type)) {
|
||||
return cache.get(type);
|
||||
@@ -85,7 +85,7 @@ public class PersistentEntitiesResourceMappings implements ResourceMappings {
|
||||
MappingResourceMetadata getMappingMetadataFor(Class<?> type) {
|
||||
|
||||
Assert.notNull(type, "Type must not be null!");
|
||||
Class<?> userType = ClassUtils.getUserClass(type);
|
||||
Class<?> userType = ProxyUtils.getUserClass(type);
|
||||
|
||||
MappingResourceMetadata mappingMetadata = mappingCache.get(userType);
|
||||
|
||||
|
||||
@@ -45,12 +45,11 @@ import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import javax.servlet.http.Part;
|
||||
|
||||
import org.springframework.core.annotation.AnnotationUtils;
|
||||
import org.springframework.data.rest.core.config.RepositoryRestConfiguration;
|
||||
import org.springframework.data.util.ProxyUtils;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.method.HandlerMethod;
|
||||
import org.springframework.web.servlet.mvc.condition.PatternsRequestCondition;
|
||||
@@ -171,7 +170,7 @@ public class BasePathAwareHandlerMapping extends RequestMappingHandlerMapping {
|
||||
@Override
|
||||
protected boolean isHandler(Class<?> beanType) {
|
||||
|
||||
Class<?> type = ClassUtils.getUserClass(beanType);
|
||||
Class<?> type = ProxyUtils.getUserClass(beanType);
|
||||
|
||||
return type.isAnnotationPresent(BasePathAwareController.class);
|
||||
}
|
||||
|
||||
@@ -35,11 +35,11 @@ import org.springframework.data.rest.core.config.RepositoryRestConfiguration;
|
||||
import org.springframework.data.rest.core.mapping.ResourceMappings;
|
||||
import org.springframework.data.rest.core.mapping.ResourceMetadata;
|
||||
import org.springframework.data.rest.webmvc.support.JpaHelper;
|
||||
import org.springframework.data.util.ProxyUtils;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.orm.jpa.support.OpenEntityManagerInViewInterceptor;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.util.StringValueResolver;
|
||||
@@ -184,7 +184,7 @@ public class RepositoryRestHandlerMapping extends BasePathAwareHandlerMapping {
|
||||
@Override
|
||||
protected boolean isHandler(Class<?> beanType) {
|
||||
|
||||
Class<?> type = ClassUtils.getUserClass(beanType);
|
||||
Class<?> type = ProxyUtils.getUserClass(beanType);
|
||||
|
||||
return AnnotationUtils.findAnnotation(type, RepositoryRestController.class) != null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user