private String typeCodeName(int sqlTypeCode) { return sqlTypeCode + "(" + JDBCToHibernateTypeHelper.getJDBCTypeName(sqlTypeCode) + ")"; }
public String columnToHibernateTypeName(TableIdentifier table, String columnName, int sqlType, int length, int precision, int scale, boolean nullable, boolean generatedIdentifier) { String preferredHibernateType = JDBCToHibernateTypeHelper.getPreferredHibernateType(sqlType, length, precision, scale, nullable, generatedIdentifier); String location = "<no info>"; if(log.isDebugEnabled()) { String info = " t:" + JDBCToHibernateTypeHelper.getJDBCTypeName( sqlType ) + " l:" + length + " p:" + precision + " s:" + scale + " n:" + nullable + " id:" + generatedIdentifier; if(table!=null) { location = TableNameQualifier.qualify(table.getCatalog(), table.getSchema(), table.getName() ) + "." + columnName + info; } else { location += " Column: " + columnName + info; } } if(preferredHibernateType==null) { log.debug("No default type found for [" + location + "] falling back to [serializable]"); return "serializable"; } else { log.debug("Default type found for [" + location + "] to [" + preferredHibernateType + "]"); return preferredHibernateType; } }
public String columnToHibernateTypeName(TableIdentifier table, String columnName, int sqlType, int length, int precision, int scale, boolean nullable, boolean generatedIdentifier) { String result = null; String location = ""; String info = " t:" + JDBCToHibernateTypeHelper.getJDBCTypeName( sqlType ) + " l:" + length + " p:" + precision + " s:" + scale + " n:" + nullable + " id:" + generatedIdentifier; if(table!=null) { location = TableNameQualifier.qualify(table.getCatalog(), table.getSchema(), table.getName() ) + "." + columnName; } else { location += " Column: " + columnName + info; } if(table!=null && columnName!=null) { result = typeForColumn.get(new TableColumnKey(table, columnName)); if(result!=null) { log.debug("explicit column mapping found for [" + location + "] to [" + result + "]"); return result; } } result = OverrideRepository.this.getPreferredHibernateType(sqlType, length, precision, scale, nullable); if(result==null) { return super.columnToHibernateTypeName(table, columnName, sqlType, length, precision, scale, nullable, generatedIdentifier); } else { log.debug("<type-mapping> found for [" + location + info + "] to [" + result + "]"); return result; } }
public void visit( 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") ); } } }