문제

I generate metamodel of my entities with the Hibernate Static Metamodel Generator Annotation Processor. So, I can build criteria properly by using field (compilation check safe) like this instead of specifying directly the field name as a string :

MyClass_.myField

I migrate old code to this new system but some functions take string as argument and not SingularAttribute (metamodel type).

I don't want to change the signature of these functions for now.

My question : can I access to the field name using the metamodel and transform it to a string ?

I would like to do something like MyClass_.myField.toString() but it does not return the name of the field.

도움이 되었습니까?

해결책

That's so easy that I don't find it immediatly...

just call :

MyClass_.myField.getName()
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top