From 79a8f43ba57d9e4a1269c5027dfd063b18d4f7d9 Mon Sep 17 00:00:00 2001 From: Guillaume Smet Date: Tue, 13 Nov 2018 20:26:33 +0100 Subject: [PATCH] HHH-13097 Don't throw an exception if there are two getter candidates --- .../bytebuddy/ByteBuddyEnhancementContext.java | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/bytecode/enhance/internal/bytebuddy/ByteBuddyEnhancementContext.java b/hibernate-core/src/main/java/org/hibernate/bytecode/enhance/internal/bytebuddy/ByteBuddyEnhancementContext.java index 1cb20ff0e6..082e73adc4 100644 --- a/hibernate-core/src/main/java/org/hibernate/bytecode/enhance/internal/bytebuddy/ByteBuddyEnhancementContext.java +++ b/hibernate-core/src/main/java/org/hibernate/bytecode/enhance/internal/bytebuddy/ByteBuddyEnhancementContext.java @@ -104,15 +104,10 @@ class ByteBuddyEnhancementContext { if ( getCandidate != null ) { if ( isCandidate != null ) { - throw new MappingException( - String.format( - Locale.ROOT, - "In trying to locate getter for property [%s], Class [%s] defined " + - "both a `get` [%s] and `is` [%s] variant", - fieldDescription.getName(), - fieldDescription.getDeclaringType().getActualName(), - getCandidate.getActualName(), - isCandidate.getActualName() ) ); + // if there are two candidates, the existing code considered there was no getter. + // not sure it's such a good idea but throwing an exception apparently throws exception + // in cases where Hibernate does not usually throw a mapping error. + return Optional.empty(); } return Optional.of( getCandidate );