jirm icon indicating copy to clipboard operation
jirm copied to clipboard

Inherited fields are not properties

Open buzden opened this issue 10 years ago • 1 comments

I'm wondering why inherited fields are not treated as properties.

In particular, in the class co.jirm.mapper.definition.SqlParameterDefinition (at the line 206) the method getDeclaredField() is used to get the field descriptor.

That makes me unable to create objects inherited from some other ones. For instance, consider the two following classes:

@Entity
public class A {
    protected final int prop;

    @JsonCreator
    public A(final @JsonProperty("prop") int prop) {
        this.prop = prop;
    }

    public int getProp() {
        return prop;
    }
}
@Entity
public class B extends A {
    protected final int another;

    @JsonCreator
    public B(
            final @JsonProperty("prop") int prop,
            final @JsonProperty("another") int another) {
        super(prop);

        this.another = another;
    }

    public int getProp() {
        return prop;
    }
}

When storing an instance of B I get the exception that prop is not a field of B. That's weird.

May be the library can't mange inheritance at all, but I hadn't found that information in the description.

buzden avatar Jun 11 '14 12:06 buzden