SimpleFlatMapper icon indicating copy to clipboard operation
SimpleFlatMapper copied to clipboard

Feature: Dump Configuration

Open chriszwickerocteris opened this issue 5 years ago • 3 comments

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!

chriszwickerocteris avatar Jul 22 '19 20:07 chriszwickerocteris

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

arnaudroger avatar Sep 13 '19 11:09 arnaudroger

Maybe both are valid use cases?

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

  • understand whether my generated code is working correctly by checking the resulting mapper configuration
  • an easy way to create a reproducing test in case I think there's something wrong in the framework

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).

chriszwickerocteris avatar Sep 16 '19 07:09 chriszwickerocteris

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

arnaudroger avatar Sep 16 '19 08:09 arnaudroger