Domanda

I am using objectdb with jpa2. I want to let my users specify the fields of my entity. How do I do that?

For example say I have an entity named Animal and I want the user to be the one specifying the name of the fields, all Strings. How would I do that? The user can be passing me a csv file with the name of the fields such as name, owner.

È stato utile?

Soluzione

You may use a Map as a persistent field in the Animal class, putting values dynamically in that map.

This, however, could be less efficient than using ordinary persistent fields.

Alternatively you can also generate entity classes dynamically using a special library (such as cglib, ASM, javassist, arch4j).

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