private void doTable(Session hSession) throws HibernateException {
    MetadataTable tTables = getMetadataTable(MetadataTable.TABLE);

    Iterator i = mClasses.values().iterator();
    while (i.hasNext()) {
      MClass hClass = (MClass) i.next();
      Set hTables = new HashSet();
      List tables = tTables.getDataRows(hClass.getPath());
      if (tables != null) {
        Iterator j = tables.iterator();
        while (j.hasNext()) {
          Metadata md = (Metadata) j.next();
          Table hTable = new Table();

          hTable.setMClass(hClass);

          hTable.setSystemName(md.getAttribute("SystemName"));

          String standardName = md.getAttribute("StandardName");
          TableStandardName tsn = lookupTableStandardName(standardName);
          if (tsn == null) {
            if (!standardName.equals("")) {
              tsn = new TableStandardName(standardName);
              mTableStandardNames.put(standardName, tsn);
              hSession.save(tsn);
            }
          }
          hTable.setStandardName(tsn);

          hTable.setLongName(md.getAttribute("LongName"));

          String tmp = md.getAttribute("DbName");
          if (tmp.startsWith("r_")) {
            hTable.setDbName(StringUtils.substring(tmp, 0, 10));
          } else {
            hTable.setDbName(StringUtils.substring("r_" + tmp, 0, 10));
          }

          hTable.setShortName(md.getAttribute("ShortName"));
          hTable.setMaximumLength(Integer.parseInt(md.getAttribute("MaximumLength")));
          hTable.setDataType(DataTypeEnum.fromString(md.getAttribute("DataType")));
          hTable.setPrecision(Integer.parseInt(md.getAttribute("Precision")));
          hTable.setSearchable(boolValue(md.getAttribute("Searchable")));
          hTable.setInterpretation(
              InterpretationEnum.fromString(md.getAttribute("Interpretation")));
          hTable.setAlignment(AlignmentEnum.fromString(md.getAttribute("Alignment")));
          hTable.setUseSeparator(boolValue(md.getAttribute("UseSeparator")));

          String editMasksJoined = md.getAttribute("EditMaskID");
          String resourcePath = hClass.getResource().getPath();
          String path = null;
          Set hEditMasks = new HashSet();
          if (editMasksJoined != null) {
            String editMasks[] = StringUtils.split(editMasksJoined, ",");

            for (int c = 0; c < editMasks.length; c++) {
              path = resourcePath + ":" + StringUtils.trimToEmpty(editMasks[c]);
              EditMask em = (EditMask) mEditMasks.get(path);
              hEditMasks.add(em);
              if (em == null) {
                LOG.error("edit mask null for path: " + path);
              }
            }
          }
          hTable.setEditMasks(hEditMasks);

          String lookupName = md.getAttribute("LookupName");
          path = resourcePath + ":" + lookupName;
          Lookup lookup = (Lookup) mLookups.get(path);
          hTable.setLookup(lookup);

          hTable.setMaxSelect(Integer.parseInt(md.getAttribute("MaxSelect")));

          hTable.setUnits(UnitEnum.fromString(md.getAttribute("Units")));

          hTable.setIndex(Integer.parseInt(md.getAttribute("Index")));

          hTable.setMinimum(Integer.parseInt(md.getAttribute("Minimum")));

          hTable.setMaximum(Integer.parseInt(md.getAttribute("Maximum")));

          hTable.setDefault(Integer.parseInt(md.getAttribute("Default")));

          hTable.setRequired(Integer.parseInt(md.getAttribute("Required")));

          String searchHelpID = md.getAttribute("SearchHelpID");
          path = resourcePath + ":" + searchHelpID;
          SearchHelp searchHelp = (SearchHelp) mSearchHelps.get(path);
          hTable.setSearchHelp(searchHelp);

          // String = md.getAttribute("unique");
          hTable.setUnique(boolValue(md.getAttribute("Unique")));

          hTable.updateLevel();

          hSession.save(hTable);
          hTables.add(hTable);
          mTables.put(hTable.getPath(), hTable);
        }
        hClass.setTables(hTables);
        hSession.saveOrUpdate(hClass);
      }
    }
  }