tk.mybatis現在のジェネリックオブジェクトエンティティクラスのテーブル名を取得します

 エッセイ、簡単な記録、

 final ParameterizedType paraType = (ParameterizedType) this.getClass().getGenericSuperclass();
        final Type[] types = paraType.getActualTypeArguments();
        String tableName = null;
        for (final Type type : types) {
            final Annotation annotation = ((Class) type).getAnnotation(Table.class);
            if (annotation == null) {
                continue;
            }
            tableName = ((Table) annotation).name();
            break;
        }

 

おすすめ

転載: blog.csdn.net/qq_38428623/article/details/106150126