OPENJPA-2877 added caching of constructor

This commit is contained in:
Thomas Andraschko 2021-10-27 11:20:41 +02:00
parent 08fe2742c1
commit 8ff3dff49b

View File

@ -199,6 +199,7 @@ public class FieldMetaData
private transient Method _extMethod = DEFAULT_METHOD; private transient Method _extMethod = DEFAULT_METHOD;
private transient Member _factMethod = DEFAULT_METHOD; private transient Member _factMethod = DEFAULT_METHOD;
private transient Constructor _converterConstructor;
private transient Method _converterExtMethod; private transient Method _converterExtMethod;
private transient Method _converterFactMethod; private transient Method _converterFactMethod;
@ -1354,7 +1355,10 @@ public class FieldMetaData
if (converter != null && val != null) { if (converter != null && val != null) {
try { try {
// TODO support CDI (OPENJPA-2714) // TODO support CDI (OPENJPA-2714)
Object instance = converter.getDeclaredConstructor().newInstance(); if (_converterConstructor == null) {
_converterConstructor = converter.getDeclaredConstructor();
}
Object instance = _converterConstructor.newInstance();
// see AttributeConverter.java from the JPA specs // see AttributeConverter.java from the JPA specs
if (_converterExtMethod == null) { if (_converterExtMethod == null) {
@ -1431,7 +1435,10 @@ public class FieldMetaData
if (converter != null && val != null) { if (converter != null && val != null) {
try { try {
// TODO support CDI (OPENJPA-2714) // TODO support CDI (OPENJPA-2714)
Object instance = converter.getDeclaredConstructor().newInstance(); if (_converterConstructor == null) {
_converterConstructor = converter.getDeclaredConstructor();
}
Object instance = _converterConstructor.newInstance();
// see AttributeConverter.java from the JPA specs // see AttributeConverter.java from the JPA specs
if (_converterFactMethod == null) { if (_converterFactMethod == null) {