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:
Oliver Drotbohm
2018-12-20 17:16:49 +01:00
parent 361be45c85
commit 13370f8e2f
5 changed files with 12 additions and 22 deletions

View File

@@ -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);
}

View File

@@ -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;
}