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