The reason for this is that the child class overrides the method from the parent class, as shown below, but since the parent class was defined as xml-transient = "true", the check below from TypeInfo fails.
child class overrides getPrimaryAddress
public class TokenizedUnitedStatesAddressData extends UnitedStatesAddressData implements TokenizedUnitedStatesAddress, CloneableAddress { @override public String getPrimaryAddress() { return primaryAddress; } }
Code violation TypeInfo.java
if (p.isTransient() && propOrderList.contains(p.getPropertyName())) { throw org.eclipse.persistence.exceptions.JAXBException.transientInProporder(p.getPropertyName()); }
UPDATE 2
The problem is not with AbstractAddress. After some debugging, the problem seems to be related to the logic below in AnnotationProcessor.getPropertyPropertiesForClass(final JavaClass cls, final TypeInfo info, final boolean onlyPublic, final boolean onlyExplicit)
if ((setMethod == null) && !(hasJAXBAnnotations(getMethod))) { // if there no corresponding setter, and not explicitly // annotated, don't process isPropertyTransient = true; }
This method will tag any method that does not have both get / set methods defined as "transitional". In my case, I override only the getPrimaryAddress()
method in the TokenizedUnitedStatesAddressData
class, and not the corresponding installer. And therefore, the Annotationprocessor
designates it as a transition property, ignoring the fact that this method is overridden.
Fix
The problem is fixed after verifying the correct processing of overridden methods when checking the transient process, as shown below.
if ((setMethod == null) && !(hasJAXBAnnotations(getMethod))) { if (!isMethodOverrriden(cls.getQualifiedName(), getMethod.getName())) { // if there no corresponding setter, and not explicitly // annotated, don't process isPropertyTransient = true; } } public static boolean isMethodOverrriden(final String classQualifiedName, final String methodName) { Method myMethod; try { myMethod = Class.forName(classQualifiedName).getMethod(methodName, null); } catch (Exception e1) { return false; } Class<?> declaringClass = myMethod.getDeclaringClass(); if (declaringClass.equals(Object.class)) { return false; } Class<?> superclass = declaringClass.getSuperclass(); if (superclass == null) { return false; } else { try { superclass.getMethod(myMethod.getName(), myMethod.getParameterTypes()); } catch (NoSuchMethodException e) { // recursively check all super classes isMethodOverrriden(superclass.getName(), methodName); } return true; } }