@@ -461,8 +461,8 @@ else if (methodName.startsWith("get") ||
461461 continue ;
462462 }
463463 boolean propertyNameMatchesFieldName = false ;
464- // convert field letter to lower case
465- methodFieldName = methodFieldName . substring ( 0 , 1 ). toLowerCase () + methodFieldName . substring ( 1 );
464+ // extract the property name from method name
465+ methodFieldName = getJavaBeansFieldName ( methodFieldName );
466466 TypeList typeList = methodDescription .getDeclaredAnnotations ().asTypeList ();
467467 if (typeList .stream ().anyMatch (typeDefinitions ->
468468 (typeDefinitions .getName ().equals ("jakarta.persistence.Transient" )))) {
@@ -476,7 +476,6 @@ else if (methodName.startsWith("get") ||
476476 for (FieldDescription ctField : methodDescription .getDeclaringType ().getDeclaredFields ()) {
477477 if (!Modifier .isStatic (ctField .getModifiers ())) {
478478 AnnotatedFieldDescription annotatedField = new AnnotatedFieldDescription (enhancementContext , ctField );
479- boolean containsPropertyAccessorMethods = false ;
480479 if (enhancementContext .isPersistentField (annotatedField )) {
481480 if (methodFieldName .equals (ctField .getActualName ())) {
482481 propertyNameMatchesFieldName = true ;
@@ -507,6 +506,22 @@ else if (methodName.startsWith("get") ||
507506 return false ;
508507 }
509508
509+ /**
510+ * If the first two characters are upper case, assume all characters are upper case to be returned as is.
511+ * Otherwise, return the name with the first character converted to lower case and the remaining part returned as is.
512+ * @param fieldName is the property accessor name to be updated following Persistence property name rules.
513+ * @return name that follows JavaBeans rules.
514+ */
515+ private static String getJavaBeansFieldName (String fieldName ) {
516+
517+ if (fieldName .length () == 0 ||
518+ (fieldName .length () > 1 && Character .isUpperCase (fieldName .charAt (0 )) && Character .isUpperCase (fieldName .charAt (1 )))
519+ ) {
520+ return fieldName ;
521+ }
522+ return Character .toLowerCase (fieldName .charAt (0 )) + fieldName .substring (1 );
523+ }
524+
510525 private static void verifyVersions (TypeDescription managedCtClass , ByteBuddyEnhancementContext enhancementContext ) {
511526 final AnnotationDescription .Loadable <EnhancementInfo > existingInfo = managedCtClass
512527 .getDeclaredAnnotations ()
0 commit comments