Modifying annotation attribute value at runtime in java

后端 未结 3 1856
失恋的感觉
失恋的感觉 2021-01-14 02:24

some methods in our model pojos have been annotated like this:

@Column(name=\"cli_clipping_id\", updatable=false, columnDefinition = \"varchar(\" + ModelUtil         


        
3条回答
  •  無奈伤痛
    2021-01-14 03:10

    I don't think the method you suggest is possible because:

    1. The annotation value which you get at runtime is actually a proxy class implementing the annotation interface. You can't set new values to its attributes.
    2. It is not possible to set new annotation values to the classes or methods at runtime.

    However, you can move to a xml based configuration for Hibernate where you can modify the parameter from outside the code.

提交回复
热议问题