When you use dynamic proxies, how do I access the Annotations base object?

When using dynamic proxies, how do I access the Annotations base object?

In particular, I annotate the settings of the ORM object using @Column ("client_id"), and then the dynamic proxy keeps track of when annotated setters are called, but ...

It does not seem that the annotated proxy server saves any of the main annotations so as not to perform reflection on every call, how to make the proxy server annotations of the Proxying class?

Thanks Allain

+4
source share
1 answer

AFAIK, it depends on your lib injection. Also remember that annotations are usually not inherited (imposed by the Java specification). If you want to access the source class and use CGLIB, you can use this snippet:

if (Enhancer.isEnhanced(getClass())) { currClass = UnEnhancer.unenhance(getClass()); } else { // else, let get the original class directly currClass = getClass(); } 
+4
source

Source: https://habr.com/ru/post/1277263/


All Articles