agentgt / jirm

A Java Immutable object Relational Mapper focused on simplicity, convenience, and thread safety.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Inherited fields are not properties

buzden opened this issue · 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.

Yes this was an oversight. There are some major updates that we have made in my company that have not been put back into the project. I'll follow up shortly.