Pergunta

In Hibernate 4.x, is there any way to get a list of persistent fields at runtime? By persistent fields I don't mean DB column names, but POJO field names or property names (depending on access type for a particular entity). Also, is there a method to get/set a persistent field's value given a field name as a string, regardless of whether it's a field or property name?

Foi útil?

Solução

It seems that everything I need (and more) is contained in ClassMetadata class (documentation).

I can get the metadata for a particular class by using SessionFactory.getClassMetadata(entityClass) and then use metadata.getPropertyNames(), etc.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top