You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jul 2, 2020. It is now read-only.
First, I'm so happy that the project is active again.
There is a bug in
com.googlecode.genericdao.search.jpa.JPAAnnotationMetadata.getProps() which
causes only direct public fields taken into consideration, so MappedSuperClass
fields or protected fields of the parent object is ignored. Here is a fix to it:
1. Add the following method to JPAAnnotationMetadata:
private static List<Field> getAllFields(List<Field> fields, Class<?> type) {
for (Field field : type.getDeclaredFields()) {
fields.add(field);
}
if (type.getSuperclass() != null) {
fields = getAllFields(fields, type.getSuperclass());
}
return fields;
}
2. Replace this code:
for (Field field : klass.getFields()) {
if (null != field.getDeclaringClass().getAnnotation(Entity.class)
|| null != field.getDeclaringClass().getAnnotation(Embeddable.class)) {
props.put(field.getName(), new Property(field));
}
}
with this one:
// genericdao has bug here. klass.getFields() only returns public fields, but all public
// and protected inherited fields should be checked.
List<Field> fields = getAllFields(new ArrayList<Field>(), klass);
for (Field field : fields) {
if (null != field.getDeclaringClass().getAnnotation(Entity.class)
|| null != field.getDeclaringClass().getAnnotation(Embeddable.class)
|| null != field.getDeclaringClass().getAnnotation(MappedSuperclass.class)) {
props.put(field.getName(), new Property(field));
}
}
Thanks,
Mohsen
Original issue reported on code.google.com by mohs...@gmail.com on 29 Apr 2013 at 5:41
The text was updated successfully, but these errors were encountered:
Original issue reported on code.google.com by
mohs...@gmail.com
on 29 Apr 2013 at 5:41The text was updated successfully, but these errors were encountered: