Question

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.

Was it helpful?

Solution

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

just call :

MyClass_.myField.getName()
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top