arnaudroger / SimpleFlatMapper

Fast and Easy mapping from database and csv to POJO. A java micro ORM, lightweight alternative to iBatis and Hibernate. Fast Csv Parser and Csv Mapper
http://simpleflatmapper.org
MIT License
435 stars 76 forks source link

1-N-M mapping with Immutables nested classes #723

Open Technohacker opened 4 years ago

Technohacker commented 4 years ago

I'm a fair bit puzzled as to how I can map this class correctly. I have the following class structure (using Immutables):

@Immutable
public interface Aaa {
    @Immutable
    public interface Bbb {
        @Immutable
        public interface Ccc {
            public abstract String foo();
            public abstract String bar();
        }

        public abstract String foo();
        public abstract String bar();
        public abstract List<Ccc> cccs();
    }

    public abstract List<Bbb> bbbs();
}

with keys on bbbs_foo and bbbs_cccs_foo, and the following SQL columns from a Spring JDBC query:

bbbs_foo, bbbs_bar, bbbs_cccs_foo, bbbs_cccs_bar

I keep getting this error:

Could not find Getter for ColumnKey [columnName=bbbs_foo, columnIndex=1, sqlType=12] returning type interface Aaa$Bbb path bbbs.{this}. See https://github.com/arnaudroger/SimpleFlatMapper/wiki/Errors_CSFM_GETTER_NOT_FOUND

I believe it's due to the nested object being an Immutables object as well, but I'm out of ideas at the moment

Technohacker commented 3 years ago

Further debugging and I found out these two scenarios lead to successful mapping:

  1. Nested plain Java classes with public fields
  2. Non-nested Immutables classes

The only issue is when I use nested Immutables. Maybe the Immutables implementation isn't found when it's nested?