title: scala read config to Map of Map of case class
body: <p>I need to read from a config file and map the config to a case class .It works fine if i have one table as  below </p>
  
  <p><strong>CONFIG</strong> </p>
  
  <pre><code>mapping {
     target {
       oracle  = {
           type = "oracle"
           schema    = "orcl"
           tableName = "my_table"
           query = "select key from my_table where dob='2020-01-01'
       }
  }
  </code></pre>
  
  <p><strong>SCALA CODE SNIPPET</strong> </p>
  
  <pre><code> val targetConfig:Map[String,QueryEngine] = config.getObject("mapping.target")
      .entrySet()
      .asScala
      .foldLeft(Map.empty[String , QueryEngine]) { case ( acc , entry ) =&gt;
        val target = entry.getKey
        val targetConfig = entry.getValue match {
          case validElement if validElement.valueType() == ConfigValueType.OBJECT  =&gt; validElement.asInstanceOf[ConfigObject].toConfig
          case invalidElement =&gt; sys.error("illegal syntax at $invalidElement")
        }
  
        targetConfig.getString("type")    match {
  
          case "oracle" =&gt; acc + (target -&gt;  new OracleQueryEngine(vars,target,targetConfig.getString("schema"),targetConfig.getString("tableName"),targetConfig.getString("query"),targetConfig.getString("param")))
  
          case  x   =&gt; sys.error(s"unknow target not defined $targetConfig with $targetConfig")
        }
      }
  </code></pre>
  
  <p>NOW i updated CONFIG with  MULTIPLE tables  in the target mapping.</p>
  
  <pre><code>mapping {
     target {
       oracle  =   
          emp = {
           type = "oracle"
           schema    = "orcl"
           tableName = "emp"
           query = "select key from emp where dob='2020-01-01'
          }
          dept = {
           type = "oracle"
           schema    = "orcl"
           tableName = "dept"
           query = "select key from dept where dob='2020-01-01'
          }
      }
  }
  </code></pre>
  
  <p><strong>CODE SNIPPET for the multiple table scenario</strong> <em>This is giving error  Expression of mutable.Set[Map[String,QueryEngine]] doesnt confirm to Map[Query,String]</em></p>
  
  <pre><code> val targetConfig:Map[String,QueryEngine] = config.getObject("mapping.target")
      .entrySet()
      .asScala
      .foldLeft(Map.empty[String , QueryEngine]) { case ( acc , entry ) =&gt;
        val target = entry.getKey
        val targetConfig = entry.getValue match {
          case validElement if validElement.valueType() == ConfigValueType.OBJECT  =&gt; validElement.asInstanceOf[ConfigObject].toConfig
          case invalidElement =&gt; sys.error("illegal syntax at $invalidElement")
        }
        targetConfig.getObject(s"mapping.target.$target").keySet().asScala.map { key =&gt;
          target  match {
            case "oracle" =&gt; acc + (target -&gt;  new OracleQueryEngine(vars,target,targetConfig.getString("schema"),targetConfig.getString("tableName"),targetConfig.getString("query"),targetConfig.getString("param")))
  
            case  x   =&gt; sys.error(s"unknow target not defined $targetConfig with $targetConfig")
          }
        }
  
    }
  </code></pre>
  
  <p><strong>PURE CONFIG  CODE</strong> </p>
  
  <pre><code>import pureconfig._
  import pureconfig.generic.ProductHint
  import pureconfig.generic.auto._
  import com.typesafe.config.ConfigFactory
  import pureconfig._
  import pureconfig.generic.auto._
  
  object PureconfigExample {
  
    case class QueryEngine(`type`: String, schema: String, tableName: String, query: String)
    type  DatabaseConfig = Map[String, Map[String, QueryEngine]]
    case class TargetConfig(target: DatabaseConfig)
    case class ApplicationConfig(mapping: TargetConfig)
  
    def main(args: Array[String]): Unit = {
      val configString =
        """
          |mapping {
          |   target {
          |     oracle {
          |        emp {
          |         type = "oracle"
          |         schema    = "orcl"
          |         tableName = "emp"
          |         query = "select key from emp where dob='2020-01-01'"
          |        }
          |        dept  {
          |         type = "oracle"
          |         schema    = "orcl"
          |         tableName = "dept"
          |         query = "select key from dept where dob='2020-01-01'"
          |        }
          |      }
          |    }
          |}
          |""".stripMargin
  
      import pureconfig.generic.auto._
  
      // See for more details - https://pureconfig.github.io/docs/overriding-behavior-for-case-classes.html
      implicit def hint[T]: ProductHint[T] = ProductHint[T](ConfigFieldMapping(CamelCase, CamelCase))
  
      val config = ConfigSource.string(configString).load[ApplicationConfig]
      println(config)
    }
  }
  </code></pre>
  
  <p><strong>POM.XML</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;project xmlns="http://maven.apache.org/POM/4.0.0"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  
      &lt;groupId&gt;test2&lt;/groupId&gt;
      &lt;artifactId&gt;test2&lt;/artifactId&gt;
      &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
  
  
  &lt;dependencies&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.github.pureconfig&lt;/groupId&gt;
          &lt;artifactId&gt;pureconfig-generic-base_2.12&lt;/artifactId&gt;
          &lt;version&gt;0.12.2&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.github.pureconfig&lt;/groupId&gt;
          &lt;artifactId&gt;pureconfig-generic_2.12&lt;/artifactId&gt;
          &lt;version&gt;0.12.0&lt;/version&gt;
      &lt;/dependency&gt;
  &lt;/dependencies&gt;
  
  &lt;/project&gt;
  </code></pre>
  
  <p><strong>COMPILER ERROR</strong> </p>
  
  <pre><code>PureConfigExample.scala
  Error:(43, 56) Cannot find an implicit instance of pureconfig.ConfigReader[PureconfigExample.ApplicationConfig].
  If you are trying to read or write a case class or sealed trait consider using PureConfig's auto derivation by adding `import pureconfig.generic.auto._`
      val config = ConfigSource.string(configString).load[ApplicationConfig]
  Error:(43, 56) not enough arguments for method load: (implicit reader: pureconfig.Derivation[pureconfig.ConfigReader[PureconfigExample.ApplicationConfig]])pureconfig.ConfigReader.Result[PureconfigExample.ApplicationConfig].
  Unspecified value parameter reader.
      val config = ConfigSource.string(configString).load[ApplicationConfig]
  </code></pre>