1515import org .apache .ddlutils .model .Column ;
1616import org .apache .ddlutils .model .Database ;
1717import org .apache .ddlutils .model .Table ;
18+ import org .apache .ddlutils .model .TypeMap ;
19+ import org .apache .ddlutils .model .JdbcTypeCategoryEnum ;
1820import org .apache .ddlutils .platform .DatabaseMetaDataWrapper ;
1921import org .apache .ddlutils .platform .mssql .MSSqlModelReader ;
2022import org .apache .ddlutils .platform .mssql .MSSqlPlatform ;
@@ -36,6 +38,7 @@ private MigrationHybrisMSSqlPlatform() {
3638
3739 public static HybrisPlatform build (DatabaseSettings databaseSettings ) {
3840 MigrationHybrisMSSqlPlatform instance = new MigrationHybrisMSSqlPlatform ();
41+ MigrationHybrisMSSqlPlatform .MSSqlHybrisTypeMap .register ();
3942 instance .provideCustomMapping ();
4043 instance .setSqlBuilder (new MigrationHybrisMSSqlBuilder (instance , databaseSettings ));
4144 MigrationHybrisMSSqlPlatform .HybrisMSSqlModelReader reader = new MigrationHybrisMSSqlPlatform .HybrisMSSqlModelReader (
@@ -63,9 +66,10 @@ private void provideCustomMapping() {
6366 platformInfo .addNativeTypeMapping (Types .SMALLINT , "INTEGER" );
6467 platformInfo .addNativeTypeMapping (Types .TINYINT , "TINYINT" , Types .TINYINT );
6568 platformInfo .addNativeTypeMapping (Types .DOUBLE , "FLOAT" , Types .DOUBLE );
66- platformInfo .addNativeTypeMapping (Types .FLOAT , "FLOAT" , Types .DOUBLE );
69+ platformInfo .addNativeTypeMapping (Types .FLOAT , "FLOAT" , Types .FLOAT );
6770 platformInfo .addNativeTypeMapping (Types .NVARCHAR , "NVARCHAR" , Types .NVARCHAR );
6871 platformInfo .addNativeTypeMapping (Types .TIME , "DATETIME2" , Types .TIMESTAMP );
72+ platformInfo .addNativeTypeMapping (Types .DATE , "DATETIME2" );
6973 platformInfo .addNativeTypeMapping (Types .TIMESTAMP , "DATETIME2" );
7074 platformInfo .addNativeTypeMapping (Types .BLOB , "VARBINARY(MAX)" );
7175 }
@@ -86,17 +90,44 @@ public void alterTables(Connection connection, Database desiredModel, boolean co
8690 this .evaluateBatch (connection , sql , continueOnError );
8791 }
8892
93+ static class MSSqlHybrisTypeMap extends TypeMap {
94+
95+ static void register () {
96+ registerJdbcType (Types .NCHAR , "NCHAR" , JdbcTypeCategoryEnum .TEXTUAL );
97+ }
98+ }
99+
89100 private static class HybrisMSSqlModelReader extends MSSqlModelReader {
90101 private static final String TABLE_NAME_KEY = "TABLE_NAME" ;
91102
92- private final Set <String > tablesToExclude = Set .of ("trace_xe_action_map" , "trace_xe_event_map" );
103+ private final Set <String > tablesToExclude = Set .of ("trace_xe_action_map" , "trace_xe_event_map" ,
104+ "change_streams_partition_scheme" , "change_streams_destination_type" );
93105
94106 public HybrisMSSqlModelReader (Platform platform ) {
95107 super (platform );
96108 }
97109
98110 protected Table readTable (DatabaseMetaDataWrapper metaData , Map values ) throws SQLException {
99- return this .tableShouldBeExcluded (values ) ? null : super .readTable (metaData , values );
111+ if (this .tableShouldBeExcluded (values )) {
112+ LOG .debug ("Table `{}` is excluded from schema read" , values .get ("TABLE_NAME" ));
113+
114+ return null ;
115+ }
116+
117+ try {
118+ return super .readTable (metaData , values );
119+ } catch (Exception e ) {
120+ LOG .error (
121+ "Error when reading schema details for table `{}` (catalog: {}, schema: {}, type: {}), message: {}" ,
122+ values .get ("TABLE_NAME" ), values .get ("TABLE_CAT" ), values .get ("TABLE_SCHEM" ),
123+ values .get ("TABLE_TYPE" ), e .getMessage ());
124+
125+ if (LOG .isDebugEnabled ()) {
126+ LOG .debug ("Table schema read error occurred" , e );
127+ }
128+ }
129+
130+ return null ;
100131 }
101132
102133 private boolean tableShouldBeExcluded (Map values ) {
0 commit comments