Chavdar Baikov created OLINGO-120:
-------------------------------------
Summary: JPA Entity parser fails if there is a boolean property
with "is" prefixed getter method
Key: OLINGO-120
URL: https://issues.apache.org/jira/browse/OLINGO-120
Project: Olingo
Issue Type: Bug
Components: odata2-jpa
Affects Versions: V2 1.0.0
Reporter: Chavdar Baikov
I am having JPA Model exposed as OData using the framework.
One of the entities contains boolean propery called "active" with pair of
generated "setter/getter" methods - "isActive/setActive".
According to the JavaBeans specification section 8.3.2:
Boolean properties
In addition, for boolean properties, we allow a getter method to match the
pattern:
public boolean is<PropertyName>();
This "isPropertyName" method may be provided instead of a "get<PropertyName>"
method, or it may be provided in addition to a "get<PropertyName>" method. In
either case, if the is<PropertyName> method is present for a boolean property
then we will use the "is<PropertyName>" method to read the property value. An
example boolean property might be:
public boolean isMarsupial(); public void setMarsupial(boolean m);
So according to the spec it should be perfectly fine.
However i am getting "Null Pointer" exceptions when trying to navigate to this
entity.
While debugging i found out that the "get" prefix is hard coded in
JPAEntityParser.
See line 150:
if (!jpaEntityAccessMap.containsKey(jpaEntityAccessKey)) {
jpaEntityAccessMap.put(jpaEntityAccessKey,
getAccessModifiers(jpaEntity, structuralType, ACCESS_MODIFIER_GET));
}
Which goes to getAccessModifiers method (line 312) and tries to find
"getActive" method and throws NoSuchMethod Exception on line 322.
accessModifierMap.put(
propertyName,
jpaEntity.getClass().getMethod(name,
(Class<?>[]) null));
My best guess is that boolean properties should be detected .. or JAVA beans
introspector could be used instead of proprietary implementation.
--
This message was sent by Atlassian JIRA
(v6.1.5#6160)