From 83f5bf8388e205b9793fde4ad971898368bcec97 Mon Sep 17 00:00:00 2001 From: Lukas Eder Date: Fri, 14 Sep 2012 09:27:39 +0200 Subject: [PATCH] [#1820] Cannot fetch into non-public POJO classes. Their members / getters / setters should be made accessible --- jOOQ/src/main/java/org/jooq/impl/Util.java | 37 +++++++++++----------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/jOOQ/src/main/java/org/jooq/impl/Util.java b/jOOQ/src/main/java/org/jooq/impl/Util.java index dca15177f6..b5beae9974 100644 --- a/jOOQ/src/main/java/org/jooq/impl/Util.java +++ b/jOOQ/src/main/java/org/jooq/impl/Util.java @@ -43,6 +43,7 @@ import static org.jooq.impl.Factory.getDataType; import static org.jooq.impl.Factory.nullSafe; import static org.jooq.impl.Factory.val; import static org.jooq.tools.StringUtils.leftPad; +import static org.jooq.tools.reflect.Reflect.accessible; import java.lang.reflect.Method; import java.lang.reflect.Modifier; @@ -789,7 +790,7 @@ final class Util { if (annotation != null) { if (name.equals(annotation.name())) { - result.add(member); + result.add(accessible(member)); } } } @@ -805,10 +806,10 @@ final class Util { for (java.lang.reflect.Field member : getInstanceMembers(type)) { if (name.equals(member.getName())) { - result.add(member); + result.add(accessible(member)); } else if (StringUtils.toCamelCaseLC(name).equals(member.getName())) { - result.add(member); + result.add(accessible(member)); } } @@ -828,7 +829,7 @@ final class Util { // Annotated setter if (method.getParameterTypes().length == 1) { - result.add(method); + result.add(accessible(method)); } // Annotated getter with matching setter @@ -841,7 +842,7 @@ final class Util { // Setter annotation is more relevant if (setter.getAnnotation(Column.class) == null) { - result.add(setter); + result.add(accessible(setter)); } } catch (NoSuchMethodException ignore) {} @@ -864,7 +865,7 @@ final class Util { // Annotated getter if (method.getParameterTypes().length == 0) { - return method; + return accessible(method); } // Annotated setter with matching getter @@ -877,7 +878,7 @@ final class Util { // Getter annotation is more relevant if (getter.getAnnotation(Column.class) == null) { - return getter; + return accessible(getter); } } catch (NoSuchMethodException ignore) {} @@ -887,7 +888,7 @@ final class Util { // Getter annotation is more relevant if (getter.getAnnotation(Column.class) == null) { - return getter; + return accessible(getter); } } catch (NoSuchMethodException ignore) {} @@ -908,16 +909,16 @@ final class Util { for (Method method : getInstanceMethods(type)) { if (method.getParameterTypes().length == 1) { if (name.equals(method.getName())) { - result.add(method); + result.add(accessible(method)); } else if (StringUtils.toCamelCaseLC(name).equals(method.getName())) { - result.add(method); + result.add(accessible(method)); } else if (("set" + name).equals(method.getName())) { - result.add(method); + result.add(accessible(method)); } else if (("set" + StringUtils.toCamelCase(name)).equals(method.getName())) { - result.add(method); + result.add(accessible(method)); } } } @@ -933,22 +934,22 @@ final class Util { for (Method method : getInstanceMethods(type)) { if (method.getParameterTypes().length == 0) { if (name.equals(method.getName())) { - return method; + return accessible(method); } else if (StringUtils.toCamelCaseLC(name).equals(method.getName())) { - return method; + return accessible(method); } else if (("get" + name).equals(method.getName())) { - return method; + return accessible(method); } else if (("get" + StringUtils.toCamelCase(name)).equals(method.getName())) { - return method; + return accessible(method); } else if (("is" + name).equals(method.getName())) { - return method; + return accessible(method); } else if (("is" + StringUtils.toCamelCase(name)).equals(method.getName())) { - return method; + return accessible(method); } } }