diff --git a/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java b/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java index 65c5609255..6fd062dfb2 100644 --- a/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java +++ b/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java @@ -56,6 +56,7 @@ import java.util.Set; import java.util.function.Predicate; import java.util.stream.Collectors; +import java.util.stream.Stream; import org.apache.openjpa.conf.OpenJPAConfiguration; import org.apache.openjpa.conf.OpenJPAConfigurationImpl; @@ -149,6 +150,10 @@ public class PCEnhancer { private static final AuxiliaryEnhancer[] _auxEnhancers; + private static final Method LONG_VALUE_OF = Stream.of(Long.class.getDeclaredMethods()) + .filter(m -> "valueOf".equals(m.getName()) && long.class == m.getParameterTypes()[0]) + .findAny().get(); + static { Class[] classes = Services.getImplementorClasses( AuxiliaryEnhancer.class, @@ -2834,7 +2839,7 @@ private void addCopyKeyFieldsFromObjectIdMethod(boolean fieldManager) throws NoS instructions.add(new VarInsnNode(Opcodes.ALOAD, 0)); // this } - if (unwrapped != type) { + if (unwrapped != type && type != Long.class) { instructions.add(new TypeInsnNode(Opcodes.NEW, Type.getInternalName(type))); instructions.add(new InsnNode(Opcodes.DUP)); } @@ -2865,10 +2870,17 @@ else if (oidType == DateId.class) { "getId", Type.getMethodDescriptor(Type.getType(unwrapped)))); if (unwrapped != type) { - instructions.add(new MethodInsnNode(Opcodes.INVOKESPECIAL, - Type.getInternalName(type), - "", - Type.getMethodDescriptor(Type.VOID_TYPE, Type.getType(unwrapped)))); + if (type == Long.class) { + instructions.add(new MethodInsnNode(Opcodes.INVOKESTATIC, + Type.getInternalName(type), + LONG_VALUE_OF.getName(), + Type.getMethodDescriptor(LONG_VALUE_OF))); + } else { + instructions.add(new MethodInsnNode(Opcodes.INVOKESPECIAL, + Type.getInternalName(type), + "", + Type.getMethodDescriptor(Type.VOID_TYPE, Type.getType(unwrapped)))); + } } } } diff --git a/openjpa-tools/openjpa-maven-plugin/pom.xml b/openjpa-tools/openjpa-maven-plugin/pom.xml index 6d6081df18..db5cb381f9 100644 --- a/openjpa-tools/openjpa-maven-plugin/pom.xml +++ b/openjpa-tools/openjpa-maven-plugin/pom.xml @@ -75,11 +75,13 @@ org.apache.maven maven-plugin-api ${min.maven.version} + provided org.apache.maven maven-compat ${min.maven.version} + provided org.apache.maven.plugin-tools