This is an automated email from the ASF dual-hosted git repository. asf-gitbox-commits pushed a commit to branch past-M2 in repository https://gitbox.apache.org/repos/asf/cayenne.git
commit 97b2dc4c470ae465cfeb3bf5b67b324313af1d19 Author: Andrus Adamchik <[email protected]> AuthorDate: Sun Jun 14 15:30:38 2026 -0400 minor performance enhancement - caching Java class in ObjAttribute --- .../src/main/java/org/apache/cayenne/map/ObjAttribute.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/cayenne/src/main/java/org/apache/cayenne/map/ObjAttribute.java b/cayenne/src/main/java/org/apache/cayenne/map/ObjAttribute.java index ba0dfa179..772f1ee00 100644 --- a/cayenne/src/main/java/org/apache/cayenne/map/ObjAttribute.java +++ b/cayenne/src/main/java/org/apache/cayenne/map/ObjAttribute.java @@ -43,6 +43,8 @@ public class ObjAttribute extends Attribute<ObjEntity, ObjAttribute, ObjRelation protected boolean lazy; protected CayennePath dbAttributePath; + private volatile Class<?> javaClass; + public ObjAttribute() { } @@ -87,12 +89,19 @@ public class ObjAttribute extends Attribute<ObjEntity, ObjAttribute, ObjRelation * Wraps any thrown exceptions into CayenneRuntimeException. */ public Class<?> getJavaClass() { + Class<?> result = javaClass; + if (result != null) { + return result; + } + if (this.getType() == null) { return null; } try { - return Util.getJavaClass(getType()); + result = Util.getJavaClass(getType()); + javaClass = result; + return result; } catch (ClassNotFoundException e) { throw new CayenneRuntimeException("Failed to load class for name '" + this.getType() + "': " + e.getMessage(), e); @@ -133,6 +142,7 @@ public class ObjAttribute extends Attribute<ObjEntity, ObjAttribute, ObjRelation */ public void setType(String type) { this.type = type; + this.javaClass = null; } /**
