code: @SuppressWarnings("unchecked")
    public static Configuration build(Configuration cfg) throws Exception {
      PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(
          DdlGenerator.class.getClassLoader());
  
      // config naming strategy
      DefaultTableNamingStrategy tableNamingStrategy = new DefaultTableNamingStrategy();
      for (Resource resource : resolver.getResources("classpath*:META-INF/beangle/table.properties"))
        tableNamingStrategy.addConfig(resource.getURL());
      RailsNamingStrategy namingStrategy = new RailsNamingStrategy();
      namingStrategy.setTableNamingStrategy(tableNamingStrategy);
      cfg.setNamingStrategy(namingStrategy);
  
      for (Resource resource : resolver.getResources("classpath*:META-INF/hibernate.cfg.xml"))
        cfg.configure(resource.getURL());
  
      for (Resource resource : resolver.getResources("classpath*:META-INF/beangle/persist*.properties")) {
        InputStream is = resource.getURL().openStream();
        Properties props = new Properties();
        if (null != is) props.load(is);
  
        Object module = props.remove("module");
        if (null == module) continue;
  
        Class<? extends AbstractPersistModule> moduleClass = (Class<? extends AbstractPersistModule>) ClassLoaders
            .loadClass(module.toString());
        addPersistInfo(cfg, moduleClass.newInstance().getConfig());
        Enumeration<String> enumer = (Enumeration<String>) props.propertyNames();
        while (enumer.hasMoreElements()) {
          String propertyName = enumer.nextElement();
          cfg.setProperty(propertyName, props.getProperty(propertyName));
        }
        IOs.close(is);
      }
      cfg.buildMappings();
      return cfg;
    }
docs: build configration
  
  @throws Exception