Domanda

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?

È stato utile?

Soluzione

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top