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
437 stars 76 forks source link

'SfmRecordMapperProvider' How to add alias by pojo type #629

Closed cn-src closed 5 years ago

arnaudroger commented 5 years ago

interesting, I don't think it's possible at the minute. the way to deal with that would be to use the @Column JPA annotation javax.persistence.Column on the class there should definitelty be another way to do that will see how we can add that.

cn-src commented 5 years ago

@arnaudroger Does SimpleFlatMapper plan to provide built-in @Column or @SfmAlias annotations?

arnaudroger commented 5 years ago

that would be very easy to add will get that with overall fix.

for the @column of jpa all you need is add that dependency

    <dependency>
        <groupId>org.eclipse.persistence</groupId>
        <artifactId>javax.persistence</artifactId>
        <version>2.2.0</version>

arnaudroger commented 5 years ago

released in 6.7.0 new @Column annotation and alias per type should be available in maven central in 30 minutes

SfmRecordMapperProvider recordMapperProvider = 
                SfmRecordMapperProviderFactory
                        .newInstance()
                        .addAliasForType(Bar.class, "barId", "id")
                        .addAliasForType(Zoom.class, "zoomId", "id")
                        .newProvider();