从休眠存储库访问 table 结构

Access table structure from hibernate Repository

我如何从控制器

访问这个值,最大值和消息

我尝试访问信息模式 table,通过 sql 访问此变量而不直接在代码中写入它,

我试图访问模式信息 table,以从列中获取最大值,但它生成了一个未映射的错误

非常感谢,抱歉,我是新手

有 2 个选项可以做到这一点。

  1. 由于该值是常量,您可以声明一个static final 变量并将其用作class 变量。 例如:

static final int MAX_RANGE = 100;

在这种情况下,只需使用"class_name"。MAX_RANGE

您还可以在 属性 文件中指定值,并在需要时使用 属性 文件。

  1. 你可以使用反射(这不是最好的情况)

    Class<?> cls = Class.forName(name); cls.getDeclaredAnnotations(); // get all annotation (cls.getDeclaredMethods()[0]).getAnnotations(); //get annotation of a method Annotation ety = cls.getAnnotation(Annotation.class); // get annotation of particular annotation class