OPENJPA-293. Fixed bug with property access and booleans and 'is' accessors.

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@567911 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Patrick Linskey 2007-08-21 02:21:44 +00:00
parent 3d22005bad
commit 7977291bea
2 changed files with 10 additions and 10 deletions
openjpa-kernel/src/main
java/org/apache/openjpa/enhance
resources/org/apache/openjpa/enhance

View File

@ -657,13 +657,6 @@ public class PCEnhancer {
return "set" + StringUtils.capitalize(fmd.getName()); return "set" + StringUtils.capitalize(fmd.getName());
} }
/**
* Return the name of the getter method for the given field.
*/
private static String getGetterName(FieldMetaData fmd) {
return "get" + StringUtils.capitalize(fmd.getName());
}
/** /**
* Return the field returned by the given method, or null if none. * Return the field returned by the given method, or null if none.
* Package-protected and static for testing. * Package-protected and static for testing.
@ -3325,8 +3318,12 @@ public class PCEnhancer {
} }
private boolean setVisibilityToSuperMethod(BCMethod method) { private boolean setVisibilityToSuperMethod(BCMethod method) {
BCMethod superMeth = _managedType.getMethods(method.getName(), BCMethod[] methods = _managedType.getMethods(method.getName(),
method.getParamTypes())[0]; method.getParamTypes());
if (methods.length == 0)
throw new UserException(_loc.get("no-accessor",
_managedType.getName(), method.getName()));
BCMethod superMeth = methods[0];
if (superMeth.isPrivate()) { if (superMeth.isPrivate()) {
method.makePrivate(); method.makePrivate();
return true; return true;
@ -3348,7 +3345,9 @@ public class PCEnhancer {
* performs any necessary field tracking. * performs any necessary field tracking.
*/ */
private void addSubclassGetMethod(FieldMetaData fmd) { private void addSubclassGetMethod(FieldMetaData fmd) {
String methName = getGetterName(fmd); String methName = "get" + StringUtils.capitalize(fmd.getName());
if (_managedType.getMethods(methName, new Class[0]).length == 0)
methName = "is" + StringUtils.capitalize(fmd.getName());
BCMethod getter = _pc.declareMethod(methName, fmd.getDeclaredType(), BCMethod getter = _pc.declareMethod(methName, fmd.getDeclaredType(),
null); null);
setVisibilityToSuperMethod(getter); setVisibilityToSuperMethod(getter);

View File

@ -194,3 +194,4 @@ subclasser-fetch-group-override: The field {1} in type {0} is configured to be \
lazily loaded, but lazy loading is not available for classes that use field\ lazily loaded, but lazy loading is not available for classes that use field\
access when not running the OpenJPA enhancer or when dynamic class \ access when not running the OpenJPA enhancer or when dynamic class \
redefinition is not available. redefinition is not available.
no-accessor: Could not find method called {0} in type {1}.