@@ -459,8 +459,8 @@ else if (methodName.startsWith("get") ||
459459 continue ;
460460 }
461461 boolean propertyNameMatchesFieldName = false ;
462- // convert field letter to lower case
463- methodFieldName = methodFieldName . substring ( 0 , 1 ). toLowerCase () + methodFieldName . substring ( 1 );
462+ // extract the property name from method name
463+ methodFieldName = getJavaBeansFieldName ( methodFieldName );
464464 TypeList typeList = methodDescription .getDeclaredAnnotations ().asTypeList ();
465465 if (typeList .stream ().anyMatch (typeDefinitions ->
466466 (typeDefinitions .getName ().equals ("jakarta.persistence.Transient" )))) {
@@ -474,7 +474,6 @@ else if (methodName.startsWith("get") ||
474474 for (FieldDescription ctField : methodDescription .getDeclaringType ().getDeclaredFields ()) {
475475 if (!Modifier .isStatic (ctField .getModifiers ())) {
476476 AnnotatedFieldDescription annotatedField = new AnnotatedFieldDescription (enhancementContext , ctField );
477- boolean containsPropertyAccessorMethods = false ;
478477 if (enhancementContext .isPersistentField (annotatedField )) {
479478 if (methodFieldName .equals (ctField .getActualName ())) {
480479 propertyNameMatchesFieldName = true ;
@@ -505,6 +504,22 @@ else if (methodName.startsWith("get") ||
505504 return false ;
506505 }
507506
507+ /**
508+ * If the first two characters are upper case, assume all characters are upper case to be returned as is.
509+ * Otherwise, return the name with the first character converted to lower case and the remaining part returned as is.
510+ * @param fieldName is the property accessor name to be updated following Persistence property name rules.
511+ * @return name that follows JavaBeans rules.
512+ */
513+ private static String getJavaBeansFieldName (String fieldName ) {
514+
515+ if (fieldName .length () == 0 ||
516+ (fieldName .length () > 1 && Character .isUpperCase (fieldName .charAt (0 )) && Character .isUpperCase (fieldName .charAt (1 )))
517+ ) {
518+ return fieldName ;
519+ }
520+ return Character .toLowerCase (fieldName .charAt (0 )) + fieldName .substring (1 );
521+ }
522+
508523 private static void verifyVersions (TypeDescription managedCtClass , ByteBuddyEnhancementContext enhancementContext ) {
509524 final AnnotationDescription .Loadable <EnhancementInfo > existingInfo = managedCtClass
510525 .getDeclaredAnnotations ()
0 commit comments