private void checkForeignKeyMapping ( List < String > errors , Config config ) { for ( Entity entity : config . getProject ( ) . getEntities ( ) . getList ( ) ) { for ( Relation relation : entity . getRelations ( ) . getList ( ) ) { if ( relation . isInverse ( ) || relation . isIntermediate ( ) ) { continue ; } for ( AttributePair attributePair : relation . getAttributePairs ( ) ) { if ( attributePair . getFromAttribute ( ) . getMappedType ( ) != attributePair . getToAttribute ( ) . getMappedType ( ) ) { String errorMsg = "Inconsistent types: Column " + attributePair . getFromAttribute ( ) . getFullColumnName ( ) + "[" + attributePair . getFromAttribute ( ) . getJdbcType ( ) + "] references column " + attributePair . getToAttribute ( ) . getFullColumnName ( ) + "[" + attributePair . getToAttribute ( ) . getJdbcType ( ) + "]. " + "You should really fix your SQL schema." ; if ( attributePair . getFromAttribute ( ) . isInCpk ( ) ) { // we may get compile failure as the property is mapped (inside the cpk) log . warn ( errorMsg + ". To avoid this error you can force the mapped type using configuration." ) ; } else { // we should not get compile failure as the property is not mapped. log . warn ( errorMsg ) ; } } } } } }
Check that foreign keys have the same mapped type as the target .