From d2a645dc9216093f59bdc5ff6421da19fb91d568 Mon Sep 17 00:00:00 2001 From: Stephane Epardaud Date: Thu, 7 Nov 2019 11:12:29 +0100 Subject: [PATCH] Panache: do not create findById bridge for abstract entity repositories If the entity type is not fixed in the hierarchy yet, don't generate the bridge Fix #5274 --- .../PanacheJpaRepositoryEnhancer.java | 38 ++++++++++--------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/extensions/panache/hibernate-orm-panache/deployment/src/main/java/io/quarkus/hibernate/orm/panache/deployment/PanacheJpaRepositoryEnhancer.java b/extensions/panache/hibernate-orm-panache/deployment/src/main/java/io/quarkus/hibernate/orm/panache/deployment/PanacheJpaRepositoryEnhancer.java index b9abe7085f1c8..5e48dfdfebbf4 100644 --- a/extensions/panache/hibernate-orm-panache/deployment/src/main/java/io/quarkus/hibernate/orm/panache/deployment/PanacheJpaRepositoryEnhancer.java +++ b/extensions/panache/hibernate-orm-panache/deployment/src/main/java/io/quarkus/hibernate/orm/panache/deployment/PanacheJpaRepositoryEnhancer.java @@ -51,24 +51,26 @@ protected String getPanacheOperationsBinaryName() { @Override public void visitEnd() { - // Bridge for findById - MethodVisitor mv = super.visitMethod(Opcodes.ACC_PUBLIC | Opcodes.ACC_SYNTHETIC | Opcodes.ACC_BRIDGE, - "findById", - "(Ljava/lang/Object;)Ljava/lang/Object;", - null, - null); - mv.visitParameter("id", 0); - mv.visitCode(); - mv.visitIntInsn(Opcodes.ALOAD, 0); - mv.visitIntInsn(Opcodes.ALOAD, 1); - mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, - daoBinaryName, - "findById", - "(Ljava/lang/Object;)" + entitySignature, false); - mv.visitInsn(Opcodes.ARETURN); - mv.visitMaxs(0, 0); - mv.visitEnd(); - + // Bridge for findById, but only if we actually know the end entity (which we don't for intermediate + // abstract repositories that haven't fixed their entity type yet + if (!"Ljava/lang/Object;".equals(entitySignature)) { + MethodVisitor mv = super.visitMethod(Opcodes.ACC_PUBLIC | Opcodes.ACC_SYNTHETIC | Opcodes.ACC_BRIDGE, + "findById", + "(Ljava/lang/Object;)Ljava/lang/Object;", + null, + null); + mv.visitParameter("id", 0); + mv.visitCode(); + mv.visitIntInsn(Opcodes.ALOAD, 0); + mv.visitIntInsn(Opcodes.ALOAD, 1); + mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, + daoBinaryName, + "findById", + "(Ljava/lang/Object;)" + entitySignature, false); + mv.visitInsn(Opcodes.ARETURN); + mv.visitMaxs(0, 0); + mv.visitEnd(); + } super.visitEnd(); }