agentgt / jirm

A Java Immutable object Relational Mapper focused on simplicity, convenience, and thread safety.
Apache License 2.0
66 stars 10 forks source link

Inherited fields are not properties #28

Open buzden opened 10 years ago

buzden commented 10 years ago

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.

agentgt commented 10 years ago

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.