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

How to customize the property name separator? #712

Closed susaiarul closed 4 years ago

susaiarul commented 4 years ago

The column aliases in the query defines the path to match the property in the POJO. Example Query:

SELECT `ticket`.`ticketid` AS `ticketId`, `ticket`.`title` AS `title`, `followers`.`userid` AS `followers.userId` FROM `ticket`

The SimpleFlatMapper Jdbc works perfect in this way to produce the POJO from the ResultSet. The question is, Is it possible to provide forward slash (/) instead of dot (.) in the column alias to match the property. For example, i would like to give `followers/userId` instead of `followers.userId` in the above query.

arnaudroger commented 4 years ago

Currently the list of separator char is set ... but you can add a

.addColumnProperty(ConstantPredicate.truePredicate(), new RenameProperty(str -> str.replaceAll("/", ".")))

it will replace all the / with a .

susaiarul commented 4 years ago

@arnaudroger Thanks for the reply. I will use the solution you have suggested.

P.S: It would be great if the list of separator is customizable, so that we can avoid the replace. Thanks once again.

arnaudroger commented 4 years ago

yes should be able to do that will keep the ticket open

arnaudroger commented 4 years ago

in 8.2.2

JdbcMapperFactory
   .newInstance()
    .propertyNameMatcherFactory(DefaultPropertyNameMatcherFactory.DEFAULT.addSeparators('/'))