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;
        }

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章