public void visit(Configuration cfg, Table table, Column col, IssueCollector pc) {
    if (currentDbTable == null) {
      return;
    }

    Column dbColumn = currentDbTable.getColumn(new Column(col.getName()));

    if (dbColumn == null) {
      pc.reportIssue(
          new Issue(
              "SCHEMA_COLUMN_MISSING",
              Issue.HIGH_PRIORITY,
              table(table) + " is missing column: " + col.getName()));
    } else {
      // TODO: this needs to be able to know if a type is truly compatible or not. Right now it
      // requires an exact match.
      // String sqlType = col.getSqlType( dialect, mapping );
      int dbTypeCode = dbColumn.getSqlTypeCode().intValue();
      int modelTypeCode = col.getSqlTypeCode(mapping);
      // TODO: sqltype name string
      if (!(dbTypeCode == modelTypeCode)) {
        pc.reportIssue(
            new Issue(
                "SCHEMA_COLUMN_TYPE_MISMATCH",
                Issue.NORMAL_PRIORITY,
                table(table)
                    + " has a wrong column type for "
                    + col.getName()
                    + ", expected: "
                    + JDBCToHibernateTypeHelper.getJDBCTypeName(modelTypeCode)
                    + " but was "
                    + JDBCToHibernateTypeHelper.getJDBCTypeName(dbTypeCode)
                    + " in db"));
      }
    }
  }
Exemple #2
0
 private String typeCodeName(int sqlTypeCode) {
   return sqlTypeCode + "(" + JDBCToHibernateTypeHelper.getJDBCTypeName(sqlTypeCode) + ")";
 }