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

Feature: Dump Configuration #669

Open chriszwickerocteris opened 5 years ago

chriszwickerocteris commented 5 years ago

When debugging a mapper configuration and creating tests, it would be great to have the possibility to get a "dump" of the mapper configuration (the column properties). Best would be to directly get the code to configure a new mapper factory.

What I imagine is a method like JdbcMapperFactory#dumpConfiguration, which would return a String that reproduces the configuration, e.g

final JdbcMapperFactory mapperFactory = JdbcMapperFactory.newInstance()
  .useAsm(false)
  .ignorePropertyNotFound()
  .addKeys("id")
  .addKeys("foo_id")
  .ignoreColumn("foo_seq_nr")
  .addColumnProperty("bar", MapTypeProperty.KEY_VALUE)
 ;

This is particularly important in a setup where different classes contribute to the mapper configuration and even more so if these classes are generated.

P.S. building on this, one could imagine directly creating the code for a reproducing test from a ResultSet and a JdbcMapper and the root class being mapped!

arnaudroger commented 4 years ago

that's at the mapper factory level, but prob want to be able to get visibility in an actual mapper underlying structure.

chriszwickerocteris commented 4 years ago

Maybe both are valid use cases?

For me, since configuration of a mapper happens across multiple (generated) classes, I'm looking for two things:

So far, I've used reflection to "dump" a factory configuration from a configured mapper for this, and it's worked quite well (easy to understand and copy/paste for a test).

arnaudroger commented 4 years ago

Yes definitely might just create another ticket for the other one and it’s also slightly trickier