From 9bc6604ff3982c169bdd2d25495560fc6ff23421 Mon Sep 17 00:00:00 2001 From: Oliver Gierke Date: Thu, 14 Apr 2016 17:07:04 +0200 Subject: [PATCH] DATAJPA-891 - Avoid creating unnecessary exceptions in JpaPersistenEntityImpl. JpaPersistentEntityImpl.isEntity() currently called a method on the JPA meta-model, catching an exception to indicate the given type is not managed. We're now rather iterate over all managed types to avoid the overhead of the exception being thrown and handled immediately. --- .../jpa/mapping/JpaPersistentPropertyImpl.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/springframework/data/jpa/mapping/JpaPersistentPropertyImpl.java b/src/main/java/org/springframework/data/jpa/mapping/JpaPersistentPropertyImpl.java index dda5cbb2a..d8ffe8646 100644 --- a/src/main/java/org/springframework/data/jpa/mapping/JpaPersistentPropertyImpl.java +++ b/src/main/java/org/springframework/data/jpa/mapping/JpaPersistentPropertyImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2015 the original author or authors. + * Copyright 2012-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. @@ -37,6 +37,7 @@ import javax.persistence.OneToOne; import javax.persistence.OrderColumn; import javax.persistence.Transient; import javax.persistence.Version; +import javax.persistence.metamodel.ManagedType; import javax.persistence.metamodel.Metamodel; import org.springframework.core.annotation.AnnotationUtils; @@ -156,12 +157,13 @@ class JpaPersistentPropertyImpl extends AnnotationBasedPersistentProperty type : metamodel.getManagedTypes()) { + if (type.getJavaType().equals(getActualType())) { + return true; + } } + + return false; } /*