public static < T > DatabaseTableConfig < T > fromClass ( ConnectionSource connectionSource , Class < T > clazz ) throws SQLException { DatabaseType databaseType = connectionSource . getDatabaseType ( ) ; String tableName = DatabaseTableConfig . extractTableName ( databaseType , clazz ) ; List < DatabaseFieldConfig > fieldConfigs = new ArrayList < DatabaseFieldConfig > ( ) ; for ( Class < ? > classWalk = clazz ; classWalk != null ; classWalk = classWalk . getSuperclass ( ) ) { for ( Field field : classWalk . getDeclaredFields ( ) ) { DatabaseFieldConfig config = configFromField ( databaseType , tableName , field ) ; if ( config != null && config . isPersisted ( ) ) { fieldConfigs . add ( config ) ; } } } if ( fieldConfigs . size ( ) == 0 ) { return null ; } else { return new DatabaseTableConfig < T > ( clazz , tableName , fieldConfigs ) ; } }
Build our list table config from a class using some annotation fu around .